+ 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);

5th Mar 2017, 3:44 AM
One Puncher
One Puncher - avatar
5 Antworten
+ 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'.
5th Mar 2017, 6:12 AM
Meharban Singh
Meharban Singh - avatar
+ 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).
5th Mar 2017, 4:22 AM
David Koplik
David Koplik - avatar
0
I tried that, but it keeps saying "Unexpected token EOF in primary"
5th Mar 2017, 3:58 AM
One Puncher
One Puncher - avatar
0
public class Program { public static void main(String[] args) { int x = 2, y = 9; int result = x * y; System.out.println(result); } }
5th Mar 2017, 4:12 AM
One Thou Wou
One Thou Wou - avatar
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//
5th Mar 2017, 1:03 PM
Rumpi
Rumpi - avatar