+ 1
Why isn't my code working?
The code is public class TheProject { public static void main(String[] args) { int x = 2; int b = 9; int result = x * y; system.out.println(result);
5 Réponses
+ 2
what??
ERROR 1:End Braces ( { ) are not present.
ERROR 2:System(S should be uppeecase)
ERROR 3: There is no variable 'y'. It is 'b'.
+ 1
You're missing ending }'s (always make sure they are closed), and it should be System, not system (uppercase S), and you have an undeclared variable used (y).
0
I tried that, but it keeps saying "Unexpected token EOF in primary"
0
public class Program
{
public static void main(String[] args) {
int x = 2, y = 9;
int result = x * y;
System.out.println(result);
}
}
0
public class TheProject{
public static void main(String[]args){
int x = 2, b = 9;
int result=x*b;
System.out.println(result);
}
}
It should work now. Don´t forget about closing curly braces and ever make sure, you use the right names for variables!
Running codes with the command promt you can ever find bugs this way:
C:\Users\*user*\>dir //"Enter"//
C:\Users\*user*\>cd *folder with your code* //"Enter"//
C:\Users\*user*\*folder with your code*\>javac CodeName.java //"Enter"//
//Between these you'll see mistakes you made in your code//