class CCircle
{
private String color;
private double pi=3.14;
private double radius;
public void steColor(String str)
{
color=str;
}
public void setRadius(double r)
{
radius=r;
}
public void setAll(String str,double r)
{
color=str;
radius=r;
}
public void show()
{
System.out.println( "color= "+color+ ",radius= "+radius);
System.out.println( "area= "+pi*radius*radius);
}
}
public class app8_1
{
public static void main(String args[])
{
CCircle cir1=new CCircle();
cir1.setColor( "Red ");
cir1.setRadius(2.0);
cir1.show();
cir1.setAll( "blue ",4.0);
cir1.show();
}
}
这是出现的错误:
C:\Java> javac app8_1.java
app8_1.java:30: 找不到符号
符号: 方法 setColor(java.lang.String)
位置: 类 CCircle
cir1.setColor( "Red ");
^
1 错误
请问大家,我应该怎么改正啊
------解决方案--------------------
public void steColor(String str)
方法名错误!setColor
------解决方案--------------------
应该
cir1.setColor(java.awt.Color.RED);