What was I thinking?

Tags - Categories : Dave | Java | Life | Review | Ubuntu

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

  1. the use of System.exit(), which either makes it non-portable, or crashes the code it gets attached to
  2. 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?


It was usefull for me
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.


Add a comment

Title
Body
HTML : b, i, blockquote, br, p, pre, a href="", ul, ol, li
Math Quiz 2 + 5 = (Helps stop blog spam)
Name
E-mail address
Website
Remember me Yes  No 

E-mail addresses are not publicly displayed, so please only leave your e-mail address if you would like to be notified when new comments are added to this blog entry (you can opt-out later).