Problem with my code running on Elipse | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Problem with my code running on Elipse

So I coded something on here, in order to get the absolute value as well as the square of any number. It works perfectly fine on this app, but when I tried to run it on Eclipse, I get a sytanx error for my for method? Code is: import java.util.Scanner; import java.lang.Math; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); int x = input.nextInt(); int square = x*x; //is it not possible on Eclipse with this syntax? if (x<0||x>0||x==0){ System.out.println(Math.abs(x)); System.out.println(square); } } }

16th Nov 2020, 10:13 AM
mad
mad - avatar
2 Answers
+ 6
Remove the second line of code where you have import lang package and then try
16th Nov 2020, 10:20 AM
Piyush
Piyush - avatar
+ 1
Ah, I additionally changed square to q and also added a "{" after the int q = x*x; and know it does not show any more syntax errors, thanks!
16th Nov 2020, 10:35 AM
mad
mad - avatar