0

My First Java Code Help

import java.util.*; /*Please dont change class name, Dcoder and class must not be public*/ //Compiler version JDK 1.8 class Dcoder { public static void main(String args[]) { System.out.println("Hello, Dcoder!"); } } public class Maths{ public static void main(String args[]) { int sum1 = 20 int sum2 = 40 int sum3 = sum1 + sum2 + 10 System.out.println(sum3); } } Please help why it is not compiling in any compiler pls fast and easy answer.

21st Dec 2017, 4:13 PM
Robin
Robin - avatar
6 odpowiedzi
+ 2
I think the problem is because of your double main method.... you can only have one per program. Try to change the name of the first main. Tell me if it fixed it.
21st Dec 2017, 6:06 PM
jaaxdev
jaaxdev - avatar
+ 2
it's Missing ; int sum1 = 20; int sum2 = 40; int sum3 = sum1 + sum2; At the end of every sentence there must be a ; Greetings
21st Dec 2017, 4:24 PM
jaaxdev
jaaxdev - avatar
+ 1
You have put 2 classes. Remove the statement 'public class Maths' and arrange the brackets that way.
21st Dec 2017, 6:05 PM
Karan Kumar
Karan Kumar - avatar
0
thanks for help.
21st Dec 2017, 4:27 PM
Robin
Robin - avatar
0
not fixed Problem In Public Class Maths what is this? when I removed Pulic there is no error but it only prints Hello Coder in Output. please help.
21st Dec 2017, 4:30 PM
Robin
Robin - avatar
0
Vhjjbxndiojfr you ht
23rd Jul 2021, 7:27 AM
DiptiMayee meher