Inheritance in Java
When i try to build and run this file on JCreator, I get
class rectangle is public, should be declared in a file named Rectangle.java
this is the code
Im trying to use inheritance to run this program, and print the volume and the area of the certain dimensions for a rectangle. I dont know how to fix this error.
public class Dimensions
a = length * width;
volume = length * width * height;
public static class Area
public static void main(String args)
Rectangle Rect = new Rectangle();
Rect.length = 7;
Rect.width = 11;
Rect.height = 5;
System.out.println("The area of a rectangle with a length of " +Rect.length + "and width " +Rect.width + "is " + Rect.a);
System.out.println("The volume of a rectangle with a length of " +Rect.length + "and width " +Rect.width + "and height of " +Rect.height + "is " + Rect.volume);
You need create class Rectangle, ant it need extends Dimensions. Well The compiler don't know what is object Rectangle.
in eclipse i got an error like "Rectangle cannot be resolved to a type" because the class Rectangle is not found. as petr already said you need to create a class Rectangle with the needed members and methods or changing the statement to Dimensions Rect = new Dimensions(); would also work.