Monday, May 9, 2011

Run java code without main method

public class test{


System.out.println("M printing :p");




As soon as class loads it will run static initializer and before it tries to search for main method, we are exiting the program with System.exit, so prints the message and then will exit normally(without throwing any exception)


  1. This really is so good that I had to comment. I'm generally just a lurker, taking in knowledge and nodding my head in quiet approval at the superior stuff?-..this required written props.
    outlook corrupt pst

  2. thanks John for again encouraging to write new posts :)