After getting to know the Java language, the next step is the first program: "Hello World" in Java.
The program is simple, its goal is to print the text "Hello World" on the console screen. Let's get started.
Preparation
As preparation, go ahead and open Eclipse, Netbeans, IntelliJ, or another editor you like. If installing anything is too much trouble, an online editor such as JDoodle works too.
That's it, that's all we need. For how to create the program file and run the code, follow the steps of your editor or IDE.
If your device is limited but you still want to code Java, try VSCode. Installation and setup are covered here. Compared with an IDE like the ones above, VSCode is relatively lighter.
Hello World Code in Java
With the code editor open, start typing.
The code is called "Hello World". As the name suggests, it prints the text "Hello World" on the console screen.
Anyway, here is the "Hello World" code in Java. Type it in your editor — or copy-paste it, that's allowed too.
public class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
Run it, and the code produces output like this:
Hello World!
Yayy.. your first Java code ran successfully👏
Next Up
Since this still counts as a warm-up, there's no need to worry about what the code means yet, we'll cover that next time.
Next up is the basic structure of Java code
Happy coding 👏