Friday, May 22, 2009

Creating Program using Java as a programming language, you can install JCreator Pro or you can write your code to notepad and compile it to MS-DOS command. But the most Advantage way is using the Jcreator Pro.JCreator hava autocomplete features and built-in methods and classes so,you can write your code faster than using any editor.


Class Declaration:

To declare a class in java you must follow the following syntax:

*modifier* class *className*{
//constructor

// main method

}

----------------------------------------------------------------------------------------------
Example:

public class {
//declaration

public (){//this is a constructor
/*statements and logic here*/

}

public static void main(String []args){
new ();//execute the class

}
}

--------------------------------------------------------------------------------------
modifier can be any of this:public, private ,default and protected. but the most common is public and private.A class that is declared public or default can be accessible to any classes while other modifier like protected and private cannot be accessible to other classes.

The Constructor must be the same name with the class. Most probably codes are written inside the constructor. And it is called in the main method to execute the code.See Example.