The so-called “Hello World” program is a small computer program that uses a simple print method to output the text “Hello World”. This shows in a simple way which instructions and components are required for a complete, executable program in a certain programming language. The “Hello World” program is often the first port of call for any programming language.
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello world");
}
}
Hello world
You can also store the string “Hello world” in a variable and then output it:
public class HelloWorld {
public static void main(String[] args) {
String msg = "Hello world";
System.out.println(msg);
}
}