Hello World in Java
- System.out.println
- System
- println
Printing Hello World on the screen is a bit more complex in Java than in many of the so-called scripting languages, but still it is probably the most simple thing you can do in the language. So let's see it.
Create a file with a name like HelloWorld.java . The extension .java is important , so is the name. In the file we create a class with the same name as the name of the file.
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
$ javac HelloWorld.java # Compiles the file and creates HelloWorld.class
$ java HelloWorld
Hello World