Java class excecutions | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Java class excecutions

My third class is not excecuting so requesting assistance.....Do we need a command so that it will move to next class...THANKS IN ADVANCE https://code.sololearn.com/cfmIqO83J2V4/?ref=app

23rd Sep 2020, 9:28 PM
Bijin Sanny
Bijin Sanny - avatar
5 Answers
+ 3
Not sure what you are trying to do. Points to remember- ▪ A Java file cannot have more than 1 public class. ▪ You can overload a main method but cannot override it. Change main1 to main in 3rd class and it should work on the playground.
23rd Sep 2020, 9:41 PM
Avinesh
Avinesh - avatar
+ 2
I think there can be just one top level class per java file... So execution of main method in MyClass1 is discarted...
23rd Sep 2020, 9:39 PM
Jesús Roberto GR 🇲🇽
Jesús Roberto GR 🇲🇽 - avatar
+ 1
Change main1 to just main. Avinesh is correct in that a normal java file can't have more than one class, but this is sololearn so they allow it. "main" tells the program where to start executing the program, that's why main1 doesn't work.
23rd Sep 2020, 11:30 PM
Odyel
Odyel - avatar
0
Thanks Avinesh, Odyel,Jesuś roberto I was just trying if Counter would accept a new entry from multiple classes but of i put main the 3 rd class was not executing so i was confused THANKS FOR ASSISTANCE 😄
24th Sep 2020, 7:17 AM
Bijin Sanny
Bijin Sanny - avatar
0
So what do we do add another class to a same program.. Import it after creating a seprate file???? And is a way to add something like a sub category of main?? Thank u for assisting.... 😊😊
24th Sep 2020, 7:20 AM
Bijin Sanny
Bijin Sanny - avatar