你用的类型不对咯 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); } }
class Person { 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(); }
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();
}
}