First Java Program…..

First program of any programming language is hello world
So here’s a twist

I will take a input from user and display it on screen…..
Basically it’s an stage which usually come after 3-5 steps of starting to learn it
But as you had already seen basic program in c/c++
So just let’s start

First open text editor and write this code in it.

Program code :

import java.util.Scanner; // importing header file for taking input

class input  // name should be same as the filename you are going to save with .java extension
public static void main(String[] args)   //don’t get confused now as you will get to know about those words later …..
Scanner input = new Scanner (; // creating object of the scanner class for taking input

String name;  //declaring string variable type to store input in it

System.out.println(“Enter your name: “);
name =;

System.out.println(” Hello “+name+” !!!”);  // + is used to concatenate hello with variable name



Enter your name:    vicky
Hello vicky !!!

Save this file as

To run this program
Open your cmd window I’m assuming that you have installed java packages in your os

Enter this command in cmd

javac now hit enter

It will compile your program.and create a new file input.class

To see output

java input now hit enter
Then you will get the output as shown above….

Go ahead and try doing this simple program and if some queries come to your mind feel free to ask.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s