I always liked to play with static initializers in Java. I remember back in the summer of 2003 i accidentally discovered the empty main pattern. Later on, a very close friend of mine, Kostantinos Saidis also found the no main pattern.
I don’t know if its bug or feature. but i sure know its fun!
Following the examples of …
Normal Class
public class Main { public static void main(String[] args) { System.out.println("Boom"); } }
Empty Main Class
public class Main { static { System.out.println("Boom!!"); } public static void main(String[] args) { //do nothing } }
No Main Pattern
public class Main { static { System.out.println("Boom!!"); } }