Java Hello World Example

42
views
Java Hello World

In this tutorial, you’ll learn to print Java Hello World which is the basic and start of your Java Programming.

This is the Basic and first Java Program which is Hello World or Java Hello World.

class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello, World!");
}
}

Output

Hello, World!

Explanation:

  1. All code is contained within a class, in this case, Hello World.
  2. The file name must match the class name and have a .java extension, for example, HelloWorld.java.
  3. All executable statements are contained within a method, in this case, named main().
  4. Use System.out.println() to print text to the terminal.

Note: 

  • Classes and methods (including other flow-control structures) are always defined in blocks of code enclosed by curly braces { }.
  • All other statements are terminated with a semi-colon (;).
  • Java language is case-sensitive! This means that HelloWorld is not the same as Hello World, nor is String the same as string.

Ask your questions and clarify your/others doubts on Java Hello World by commenting. Java Documentation.

PREVIOUS
JAVA BASIC SYNTAX
NEXT
JAVA COMMENTS