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"
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