JAVA7 : "Hello World" Example

This tutorial elaborate a simple example of JAVA 7.

JAVA7 : "Hello World" Example

This tutorial elaborate a simple example of JAVA 7.

 Creating Java Program :

Before writing java program we must take a look on java programming syntax and then we will discuss basic example.

If you have knowledge of C++ then you will easily understand java syntax. Most of java syntax is extracted from C++. It contains syntax for object oriented programming, structured and generic.
Since JAVA is based on object oriented concept so everything is written inside the class. Primitive data types are exception. also java does not support operator overloading or multiple inheritance.
There is two kinds of comments provided by the java. These are -

  1. // This is first type java comment.
  2. /* This is another way of java comment */

You can build a java program on Notepad or by using different IDEs like EditPlus, eclipse, NetBeans etc.

If you are writing java program on notepad then you need to start command prompt for compiling and executing. Suppose Your java program name is then compile it as-

> javac

For running program write -

>Java HelloWorld.

IDEs consists of a source code editor, build automation tools and a debugger which helps you to execute program easily.

The following image shows how java program execute -

Example :

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

Description : Here we are using Eclipse IDE to write java program.

public static void main(String[] args)

Here public shows that it is accessible to all.
static represents that it may execute without an object instance.
void shows that it returns nothing.
main method is beginning point of java program execution.
System.out.println(?Hello World?). display your content on console.
To execute this program press ctrl+f11 or right click on the file and select run as, then java application.
After execution, we can see our output on console.

Output :

Hello World!


Share on Google+Share on Google+

JAVA7 : "Hello World" Example

Posted on: December 12, 2012 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: JAVA7 : "Hello World" Example  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image