public class Test {
/**
* @param args
*/
// 1st way
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Test....!!!!!");
}
// 2nd way
static{
System.out.println("Test....!!!!!");
System.exit(1);
}
// 3rd way
private static int i = m1();
public static int m1(){
System.out.println("Test...!!!!");
System.exit(0);
return 0;
}
Other than this, can we print message any other way.
main()
? #2 and #3 do not work unless somemain()
method was ever called that loaded a class containing such declarations. – Mcspadden