public class Person
{
String name;
int age;
int stID;
public String getName(){
return name;
}
public void setName(String aname){
name=aname;
}
public int getAge(){
return age;
}
public void setAge(int aage){
age=aage;
}
public int getStID(){
return stID;
}
public void setStID(int astID){
stID=astID;
}
public static void main(String[] args)
{
Person st1=new Person();
Person st2=new Person();
st1.setName("F");
st1.setAge(23);
st1.setStID(1);
st2.setStID(2);
st2.setName("S");
st2.setAge(24);
System.out.println(st1.getStID()+'\n'+st1.getName()+'\n'+st1.getAge());
System.out.println();
System.out.println(st2.getStID());
System.out.println(st2.getName());
System.out.println(st2.getAge());
}
}
结果:
11F
23
2
S
24
为什么会生成11F的结果?