I am a newbie in Java. I have done this following program using extend keyword in Java.I am using Netbeans Ide.My below program is correct it is given on the book Programming with JAVA by E Balagurusamy.
package room; public class Room { int length; int breadth; Room(int x, int y){ length=x; breadth=y; } int area() { return (length*breadth); } class BedRoom extends Room{ int height; BedRoom(int x,int y,int z){ super (x , y); height=z; } int volume() { return (length*breadth*height); } } class InherTest{ public static void main (String [] args){ Bedroom room1 =new BedRoom(14,12,10); int area1=room1.area(); int volume1=room1.volume(); System.out.println("Area1="+area1); System.out.println("Volume="+volume); } }
now my question is there is an error on line public static void main (String [] args)
and the error is:
Illegal static declaration in inner class Room.InherTest modifier 'static' is only allowed in constant variable declarations
What is the meaning of this error?
and how to solve the error?