Relative Content

Tag Archive for javaphpclassexceptioncompilation

“error: can’t find main(String[]) method in class: ” when class put before public class

In a java code if I put the non-public class before public class this error pops up.
ref1
But, if I put it after the public class, it does not.
Here I put the class after the public class and it does not show any error.
ref2
This seems to be the case with my compiler alone because I saw creators on YT doing the same thing and it works for them.
Though I know it’s not a major issue and I can just create the class below the public class, I would still like to know why it happens. Does it have something to do with my PC or is there some setting I need to toggle?
Thanks!

“error: can’t find main(String[]) method in class: ” when class put before public class

In a java code if I put the non-public class before public class this error pops up.
ref1
But, if I put it after the public class, it does not.
Here I put the class after the public class and it does not show any error.
ref2
This seems to be the case with my compiler alone because I saw creators on YT doing the same thing and it works for them.
Though I know it’s not a major issue and I can just create the class below the public class, I would still like to know why it happens. Does it have something to do with my PC or is there some setting I need to toggle?
Thanks!