This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

main()

 
cybel sheriden
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can main() be private.k&b says tht for the exam assume main() is public.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try compiling this:
 
James Carman
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, that will compile. Try running that!
 
miguel lisboa
Ranch Hand
Posts: 1281
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

oops
i meant that
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prior to Java 1.4, main was not required to be public.

This was reported as a bug in 1.2.2, then closed with the curious determination, "will not be fixed."

Ref: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4252539

Fortunately, it was fixed, and main (as an entry point) is now required to be public.
 
James Carman
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know that it's really that big of a deal if it's private, do you? It seems obvious that it should be public, though.
 
Surasak Leenapongpanit
Ranch Hand
Posts: 341
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

When I run this code on JVM1.4.2, it complains "Main method not public.".
[ March 11, 2005: Message edited by: Surasak Leenapongpanit ]
 
James Carman
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Surasak Leenapongpanit:

When I run this code on JVM1.4.2, it complains "Main method not public.".

[ March 11, 2005: Message edited by: Surasak Leenapongpanit ]


That's the point!
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Carman:
I don't know that it's really that big of a deal if it's private, do you? It seems obvious that it should be public, though.

Yes, it certainly makes sense that it's required to be public. But because it's an "entry method," it seems a bit on the fringe, so I don't know how big of a deal this might be.

In other words, the initial call to main is not coming from another object, or even a static method of another class. So in this special case, since we're telling to JVM to load the class and invoke main, might we even consider this a de facto call from within the same class?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic