Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

main is private , but the code compiles and run why

 
faisal usmani
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello , Why this code compiles and execute , the main method is private here

class Demo
{
private static void main ( String ka [ ] )
{
System.out.println ( "faisal usmani" );
}
}

Thanx in advance
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you certain your code works?

 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joe Ess:
Are you certain your code works?



I'm sure it worked in earlier versions of Java. It was a JVM bug, although a minor one...
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ilja Preuss:
...I'm sure it worked in earlier versions of Java. It was a JVM bug, although a minor one...

Yes, prior to Java 1.4, main was not required to be public.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic