我从互联网复制了一个代码,并对其进行了一些更改。突然在第131行(下方)Cirlce cannot be resolved to a type
中说出了什么情况?++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++(对所有这些人表示抱歉,但是Stackoverflow神秘地说道:“看起来您的帖子大部分是代码;请添加更多详细信息。”在这里,您有“必要的”详细信息!
import java.io.*;
interface Shape
{
// abstract method
void draw();
double area();
double volume();
}
class Rectangle implements Shape
{
int length, width, height;
// constructor
Rectangle(int length, int width, int height)
{
this.length = length;
this.width = width;
this.height = height;
}
@Override
public void draw()
{
System.out.println("Rectangle has been drawn ");
}
@Override
public double area()
{
return (double)(length*width);
}
public double volume()
{
return (double) (length*width*height);
}
class Circle implements Shape
{
double pi = 3.14;
int radius;
//constructor
Circle(int radius)
{
this.radius = radius;
}
@Override
public void draw()
{
System.out.println("Circle has been drawn ");
}
@Override
public double area()
{
return (double)((pi*radius*radius)/2);
}
public double volume()
{
return (double) 4/3*(Math.pow(radius,3));
}
}
}
class Demo
{
public static void main (String[] args)
{
// creating the Object of Rectangle class
// and using shape interface reference.
Shape rect = new Rectangle(2,3,4);
System.out.println("Area of rectangle: " + rect.area()+ "and volume is " + rect.volume());
// creating the Objects of circle class
Shape circle = new Circle(2); // LINE 131
System.out.println("Area of circle: " + circle.area() + circle.volume());
}
}
您在Circle
内定义了Rectangle
,但第131行不遵守此规定。