Static block is not executing in JDK 7, “Main method not found”, but works in JDK 1.5

前端 未结 9 2145
我寻月下人不归
我寻月下人不归 2021-01-07 20:19

I have written a simple class with one static block

class Hello
{

  static {
           System.out.println(\"Hello\");
       System.exit(0);
     }
}
         


        
9条回答
  •  萌比男神i
    2021-01-07 21:05

    You cannot execute a java program without main method unless otherwise it is an applet or something else. I say your observation on jdks might be wrong

提交回复
热议问题