I have the following simple hello world in Java:
class A {
static {
System.out.println(\"Hello world\");
}
}
It works as ex
It works as expected, but oddly: No. class gets loaded. And when a class is loaded, its static blocks are executed.
Why you get Exception in thread "main" java.lang.NoSuchMethodError: main
Because in first case you dont have a main method and in second case signature is not correct.
change it to public static void main(String a[])