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 !
本文分享了一个简单的Java程序——Hello World。通过这个例子,介绍了Java中类的定义、main方法的正确用法以及如何避免常见的错误。对于初学者来说,这是一个很好的起点。

被折叠的 条评论
为什么被折叠?



