Pages

Tuesday, 1 July 2014

What is Java Class?

What is Java Class?
Java class is nothing but a template for object you are going to create or it’s a blue print by using this we create an object. In simple word we can say it’s a specification or a pattern which we define and every object we define will follow that pattern.

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

Save with .java extension , like Hello.java
Explain :
        In above example, Hello is a class and program print "Hello World"

Note: class name is case t. so be careful. String [S later capital] System [S later capital]
           Run program as same name, like, if you run program in CMD then write

javac Hello.java       [Compile program]
java Hello                [Run program]

No comments:

Post a Comment