| Author |
main
|
hemamalini s.
Greenhorn
Joined: Oct 17, 2005
Posts: 13
|
|
Why main() method must be public so that it be called from JVM? why class name may not be public in which main method is there cause ?JVM is outside the class>...........
|
 |
Patrick Punty
Greenhorn
Joined: Jul 01, 2005
Posts: 24
|
|
Well for your first querry I feel the answer is Yes, so that JVM can call it. and I am sorry I didnt get your second querry
|
 |
Raghu Shree
Ranch Hand
Joined: Mar 18, 2005
Posts: 143
|
|
Hi, Public methods are only accessible from outside of the class. main() method is the entry point of the java applications. so we should declare the main method as public.
|
Raghu J<br />SCJP 1.4<br /> <br />The Wind and waters are always<br />on the side of the ablest navigators.<br /><a href="http://groups.yahoo.com/group/scjp_share" target="_blank" rel="nofollow">SCJP Group</a><br /><a href="http://groups.yahoo.com/group/JavaBeat_SCWCD" target="_blank" rel="nofollow">SCWCD Group</a>
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
|
main was not required to be public until Java 1.4.
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
hemamalini s.
Greenhorn
Joined: Oct 17, 2005
Posts: 13
|
|
jvm is outside the class . it can call public main() method.it is right.but what if class is in default access and public main is there.then also it is able to call it. I just want to ask how JVM enters a non-public class?
|
 |
 |
|
|
subject: main
|
|
|