Hello world in Java

Hello everyone ! This is my first blog. The following is a hello world program in Java.

class hello {
      public static void main(String args[]) {
          System.out.println("hello world !");
      }
  }

Attention:

1) While you are writing this program, you should pass "String args[]" as the argument to the main method.

     If you do not pass an array of String as an argument, it will cause this exception:        

         Exception in thread "main" java.lang.NoSuchMethodError: main. 

2) When you write a method , you'd better write the return type directly in front of the method name.

   public static void main() { ... }  // OK
   public void static main() { ... }  // error ! 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章