You can find the post over here.
The 'trick' involves a static initialiser to print the String, and then calling an explicit exit().
Nice work in using Google's syntaxhighlighter on the code, very pretty.
I'd happy if anyone could point out a real-world application of the code shown, or a reason that knowing this 'trick' makes you a better developer.
The two main points that grate are
- the use of System.exit(), which either makes it non-portable, or crashes the code it gets attached to
- The fact that it fails to initialise the Class, which would result in (if memory serves) a ClassNotFoundException when accessed from that point on.
Agreed that these points are only meaningful if you use the code in conjunction with other code, but then again explain the use of code that cannot be used?
Comments[2]
Posted by davo on 27 July 2008 10:15:56
Reply |
Permalink
Re: Not saying "hello World" without main Method
It was usefull for me
Comment from Saeed Zarinfam on 28 July 2008 22:20:32
Presumably, the point it to show off mastery of an arcane detail of the Java VM implementation. How that correlates to being able to use the language for useful purposes, one can only speculate.
Comment from Ulf on 29 July 2008 15:09:23

