Learn Java by Starting from First Program - Hello World

It's always exciting to write your first program and execute it without error. In this post you will learn to write your first java program.

Pre-Requisite Softwares :

1. Java SE Development Kit or JDK  - It is generally a Java Software which you need to install on your system before writing any code in Java. And after installing java set Java Path in your environment variables.

  • Download Latest Java Version from following link - Java Download
2. Java IDE or Text Editor - You need to have any text editor to write Java code. You can use anyone from following Netbeans, Intellij, Eclipse, Notepad or Notepad++ etc.

Creating Hello World Program
  • Declare a class 'MyFirstProgram'
  • Declare the main method public static void main()
  • And print a string "Hello World" using System.out.println()
Hello World Program

// Class
class MyFirstProgram {
 // Main method
 public static void main(String[] args) {
  // Print Hello World
  System.out.println("Hello World");


Java Keywords used in 'Hello World' Program
  • class keyword is used to declare a class.
  • Public is an access modifier which defines main method's accessibility. Public means main method is global or accessible to all other classes in the project.
  • static is a keyword in java, when static is used with any method then it is called static method. Static method can be called without creating the object of the class.
  • main is the method name and also the execution point of any program. Main method is required to execute the program.
  • String[] args is an array of string is basically for command line arguments.
  • System.out.println() is used to print any statement. 
    • System is a class
    • out is the object of PrintStream class
    • println() is method of PrintStream class

Run the First Program:
  • If you are using Eclipse then you can run this program by just clicking the green play button displayed on the top bar. 
  • Or right click anywhere in the class and click 'Run as Java Program'.

  • Hello World - will be displayed in the console
Click here to find complete Java Tutorials Series

JDK, JRE & JVM  << Previous      ||      Next >>  Java Variables

Follow Us

Quora Space | Facebook Page | Telegram Channel
Feel free to ask queries or share your thoughts in comments or email us.


Popular posts from this blog

10 Best Demo Websites for Automation Testing Practice

Automate 'User Registration' of E-commerce Website using Selenium

Automate E-Commerce Website using Selenium Webdriver

Automate Browser Actions on Godaddy.com using Selenium