iPhone – HelloWorld program in java..

Welcome to the java world.This is an simple HelloWorld example.

If you are new to programs ,Basic Terms you should know before the code:

Class:

Class is an collection of objects.it is an wrapper for the objects.

Example:Classroom(Classroom contains benches,boards etc)

Object

Everything is considered to be an object.Especially in java everything is an object.Remember java is used for platform independent and real life entity mapping too.

Example:pen,bike,cap….

Method:

Method is a collection of code which are called to do a specific task.

Example:Brakes in a vehicle…

Variable:

Variable are used to store values which are used later for computations.

Example:Wallet,box…

CODE:

public class HelloWorld {

public static void main(String[] args) {

 System.out.println(“HelloWorld”);
    }
}

OUTPUT:

Explanation:

public class HelloWorld {

  • HelloWorld is the class name and its access specifier is public so it can be accessed from any other classes.

public static void main(String[] args) {

  • Here public is the access specifier so the is accessible for other class.
  • It is static so it has only single memory.
  • void is the return type of this method so the method wont return any values.
  • String[] args is the parameter passed to this method.

System.out.println(“HelloWorld”);

  • This line prints the value ‘HelloWorld’.
  • Here println() is a method.
  • out is an object.
  • System is a class name.
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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