Friday, March 6, 2009

with out main with out static block



package something;

public class Withoutmain {
static int i=m1();
public static int m1()
{
System.out.println("hi I can print");
return 10;
}
}

output:
hi I can print
Exception in thread 'main' java.lang.NoSuchMethodError:main

2 comments:

Unknown said...

(without Exception)

public class Withoutmain {
static int i=m1();
public static int m1()
{
System.out.println("hi I can print");
System.exit(0);
return 10;

}
}
o/p:hi I can print

Anonymous said...

How does this works
can any body explain?

Post a Comment