JavaOC
 
 


Do you show this ugly Hello World in your first Java lesson?

  class HelloWorld
{
  public static void main(String[] args)
  {
    System.out.print("Hello world!");
  }
}
 

How do you explain then what is public, static and the String array? Better show this full-fledged OO program and say: "When the HelloWorld object is created, the constructor is executed".

  class HelloWorld
{
  HelloWorld()
  {
    System.out.print("Hello world!");
  }
}
 

You compile the source program as usual with javac HelloWorld.java (or your favorite IDE). To run the program without main, you just replace java by javaoc (resp. javaw by javaocw). To have backward compatibilty, javaoc resp. javaocw will invoke main, when it is present.