why we are using public word before main function

Recommended Answers

All 2 Replies

static Main method will be invoked by JVM which is outside of package. So we should use public access specifier for main method. Otherwise method will not be visible for Jvm.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.