qq_40806755
秋秋秋i
2017-10-26 15:20

求解输出为啥都是王五

  • 求解

package basic;

class Student{
public String name;
public int age;
public Student(String name,int age){
this.name =name;
this.age=age;

}

}
public class Test {
private static void ref(Student s){
s.name ="wangwu";
s.age=12;
}
public static void main(String[] args) {
Student st = new Student("zs", 20);
Student st1=st;
ref(st1);
System.out.println(st.name +st.age);
System.out.println(st1.name +st1.age);
}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答