p1.breathe="good";
p2.breathe="poll";
你定义的breathe为char,但是却赋值为String,类型错误。把char breathe;
改成String breathe;就可以了。
p2.breathe="poll";
你定义的breathe为char,但是却赋值为String,类型错误。把char breathe;
改成String breathe;就可以了。
调试欢乐多
class Person
{
int age;
char breathe; //这里应该使用:String breathe;
void shout()
{
System.out.println("oh,my god! my age is" +age);
System.out.println("oh,my god! my breathe is" +breathe);
}
}
{
int age;
String breathe; //改为这样就可以了。
void shout()
{
System.out.println("oh,my god! my age is" +age);
System.out.println("oh,my god! my breathe is" +breathe);
}
public static void main(String[] args)
{
Person p1=new Person();
Person p2=new Person();
p1.age=-30;
p1.breathe="good";
p2.breathe="poll";
p1.shout();
p2.shout();
}
}