Hello World
Below is the source code for a traditional Hello World program.
Activity
- Try changing the message from
Hello Worldto your name and click Run again. - If everything worked without an error, congratulations, you have just run your first Java program.
//This is a comment and will be ignored by the Java compiler
//The program is fully editable
//Try changing the 'Hello World, I'm a Java program'
//to your name and click the Run button
public class HelloWorld {
//This is the main function of a Java program.
public static void main (String[] args) {
//The System.out.println() is used to print output to the console
System.out.println("Hello World, I'm a Java program");
}
}