Hey i think the only mistake in ur code was tat u didnt declared the attributes as the class members rather it was a part of the main's local variables....



u could use the code like this::


class Boxers
{

double width=0.0;
double height=0.0;
double depth=0.0;



public static void main(String args[])
{

Boxers box1=new Boxers();
Boxers box2=new Boxers();

box1.width=27;
box1.height=23;
box1.depth=43;

box2.width=21;
box2.height=24;
box2.depth=32;

box1.volume();
box2.volume();

void volume()
{

System.out.println("the volume of the box is: "+(width*height*depth));

}

}
}