Hello world in Java

来源:互联网 发布:倪妮微博照片修图软件 编辑:程序博客网 时间:2024/04/17 05:35

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 ! 

原创粉丝点击