+ 3
Why the main method in java is public and static?
2 odpowiedzi
+ 1
It's public so that it may be called from outside the class. It's static because otherwise you'd need to create an instance of the class first. There are other reasons, but once you've learned about access modifiers and static, this should make perfect sense to you.
https://stackoverflow.com/questions/22328302/why-main-is-declared-public-and-static-in-java
+ 1
It is public beacuse at execution compiler calls it from outside of the class and it is static beacause compiler calls it without making the instance of class