Posts

Showing posts with the label declare object of class in java

Classes in Java

Class? Class is template or blueprint. The most important thing to understand about a class is that it  defines  a new data type. Variables defined within a class are called instance variables because each instance of the class contains its copy of these variables.   Class declaration Method : class ClassName { Instance Variables:   type instanceVariable1;   type instanceVariable2;   . . .   type instanceVariableN; Methods in Class:   type methodName1(parameterList){   //body of method and code   }   type methodName2(parameterList){   //body of method   }   . . .   type methodNameN(parameterList){   //body of method and code   } } Declare Object of class: Classname objectname = new classname(); For Example Student stud = new Student();