java中賦值問題

public class ReferenceTest {this

static class Student{
    public Bag b;
    public int a;
    public String s;
    public String getS() {
        return s;
    }
    public void setS(String s) {
        this.s = s;
    }
    public int getA() {
        return a;
    }
    public void setA(int a) {
        this.a = a;
    }
    public Bag getB() {
        return b;
    }
    public void setB(Bag b) {
        this.b = b;
    }
}

static class Bag{code

public String name;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}
public static void main(String[] args) {
    //引用

// Student student = new Student();
// Bag bag1= student.b;
// System.out.println(bag1);
// student.b = new Bag();
// System.out.println(bag1);
//8種基本變量
// Student student = new Student();
// int a= student.a;
// System.out.println(a);
// student.a = 1;
// System.out.println(a);
//字符串
// Student student = new Student();
// String s= student.s;
// System.out.println(s);
// student.s = "s";
// System.out.println(s);
//// int a=0;
// int b =a;
// System.out.println(b);
// a=1;
// System.out.println(b);
String s = "s";字符串

String s1 = s;
    System.out.println(s1);
    s="s2";
    System.out.println(s1);
}

}get

相關文章
相關標籤/搜索