This is the program every Java programmer knows. It is simple, but a simple start may lead to deep understanding of more complex stuff. It would be great if this post is interesting to read, not only for entry-level Java programmers. Please leave your comments if hello world means more to you.
public class HelloWorld {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hello World");
}
}
1.Why Everying Starts with a Class?
Java programs are built from classes, every method and field has to be in a class. This is due to its object-oriented feature. Object-oriented programming languages have a lot of advantages such as modularity, extensibility, etc.
2.Then Main method -- Program Entrance
The main method is the program entrance and it is static. "static" means that the method is part of its class. not part of objects.
Why is that? Why don't we put a non-static method as progtam entrance?