Thursday, December 8, 2011

Static in java

If you want print something in java without using static blocks or main method.


class Google
{
    static int i=m1();`
    public static int m1()
    {
        System.out.println("Hi......");
        return 10;
    }
}
---------- Output ----------
Hi......
java.lang.NoSuchMethodError: main
Exception in thread "main"

No comments:

Post a Comment