0

main method() in java is always in public class.

Why is it necessary to have main method always in public class for compilers like netbeans? Also if we use online compiler sometimes it's not necessary.

8th Jun 2018, 1:34 PM
harshit
harshit - avatar
5 Respostas
+ 2
because main is the entry point of your program, so it needs to be visible from outside your class
8th Jun 2018, 2:27 PM
Max
Max - avatar
+ 2
can to link me to any of those?
9th Jun 2018, 8:10 AM
Max
Max - avatar
0
But why in many online compilers if we not mention public in class of main() still the program runs.?
9th Jun 2018, 8:01 AM
harshit
harshit - avatar
0
Try Dcoder app which compiles online.
9th Jun 2018, 8:21 AM
harshit
harshit - avatar