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
/*statements and logic here*/
}
public static void main(String []args){
new
}
}
--------------------------------------------------------------------------------------
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.
