Core Java

HelloWorld.java – Java Program to Print Hello World

Java Beginners’ first example program to print Hello World.

1. Introduction

In this tutorial, We’ll learn how to print “Hello World” in java. This is called as first java program to beginners to the programming language. If you understand each and every word in this program then you are good to start learning java concepts.

2. Java Hello World Program

The following is the program is the basic and introductory program for
freshers or graduate students.

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
package com.java.w3schools.blog.java.program.to;
 
/**
 *
 * hello world program in java.
 *
 * @author JavaProgramTo.com
 *
 */
public class HelloWorld {
 
 public static void main(String[] args) {
 
  System.out.print("Hello World!");
 
 }
 
}

Output:

1
Hello World!

3. Understand Hello World Program

If a java program has main() method means that the main() method will be invoked by JVM when you run it. But, Every program needs not to have a main() method and it is optional.

Understand “public static void main()” which is already discussed in previous articles.

And also need to understand “System.out.println()”.

System: It is a class in java.lang package and it works with standard input and output streams. That means reading and printing the values on to the console.

out: out is an instance of PrintStream class. out is a static variable that can be accessed with a class name directly. Object creation is not required to call static members.

println(): println() method is a static method and it is called on out variable.

4. Conclusion

In this article, We’ve seen how to print “Hello World” in java and understanding each keyword in it with an example program.

GitHub Code

Published on Java Code Geeks with permission by Venkatesh, partner at our JCG program. See the original article here: HelloWorld.java – Java Program to Print Hello World

Opinions expressed by Java Code Geeks contributors are their own.

Venkatesh Nukala

Venkatesh Nukala is a Software Engineer working for Online Payments Industry Leading company. In my free time, I would love to spend time with family and write articles on technical blogs. More on JavaProgramTo.com
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button