+ 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); } } }
2 odpowiedzi
+ 6
Remove the second line of code where you have import lang package and then try
+ 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!