In this lesson, we will learn to write a Java Hello World Program. This is the first program we will write in the course and it’s the first program anyone write once they start their learning of any programming language.Our Java Hello World program is a simple Java program that will produce an output of “Hello World!
“. Without any delay let’s write our first Java program together.
Here is our first Java Hello World program. I encourage you to write this code in your IDE and not copy paste to get the better feeling 🙂
package com.javdevjoural;
public class HelloWorld {
public static void main(String[] args) {
//print Hello World!!
System.out.println("Hello World!");
}
}
Output
Hello World!
Now we have written our first program, let’s see how the program works
HelloWorld
.
public class HelloWorld{
MyFile.java
while the class name id HelloWorld.java
. We need to make sure the file name is also set as HelloWorld.java
.The public static void main(String[] args)
is the main method. Every Java application must have a class with main() method. This is the entry point for our compiler to start executing the code.
main()
method in more details in the next lesson.In this lesson, we wrote Java Hello World Program that is our first program in Java. As always the entire source code for this series is available on our GitHub repository.