Introducing Classes
Introducing Classes
class classname
{
type instance-variable1;
type instance-variable2;
type instance-variableN;
type methodname1(parameter-list)
{
// body of method
}
type methodname2(parameter-list)
{
// body of method
}
type methodnameN(parameter-list)
{
// body of method
}
}
A Simple Class
class Box
{
Class- Variables double width;
double height;
class Box double depth;
{ }
class BoxDemo
double width; {
double height; public static void main(String args[])
{
double depth; Box mybox = new Box();
} double vol;
mybox.width = 10;
Class- Object mybox.height = 20;
mybox.depth = 15;