Results 1 to 2 of 2
Thread: Private main method
- 12-21-2007, 09:31 AM #1
Senior Member
- Join Date
- Nov 2007
- Posts
- 111
- Rep Power
- 0
Private main method
I tried the following:
It does not give me any errors at compile time (I am using Eclipse 3.3). When I try to run it, it says "Main method not public". Makes sense.Java Code:public class T { private static void main(String[] str) { System.out.println("test"); } }
But I would like to know, why main method should always be public. This method is not called by other classes directly.
- 12-21-2007, 09:45 AM #2
Check these out, particularly the last one. It appears to vary among different versions of Java, and overall I can't find an exact answer other than, Java says so. :)
Portability & Platform Independence [Archive] - private main method
doubt in public static void main
Why is main() public? (Programmer Certification (SCJP) forum at JavaRanch)
Similar Threads
-
Calling main method
By eva in forum New To JavaReplies: 7Last Post: 11-06-2009, 01:37 PM -
Main method with throws Exception
By bugger in forum New To JavaReplies: 3Last Post: 01-07-2008, 02:48 PM -
A query about main method
By mew in forum New To JavaReplies: 2Last Post: 12-24-2007, 09:44 AM -
main method
By eva in forum New To JavaReplies: 5Last Post: 12-19-2007, 09:25 AM -
The main method in java...
By lenny in forum New To JavaReplies: 1Last Post: 07-31-2007, 06:21 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks