package com.c9;
import java.util.ArrayList;
//值传递,还是引用传递?
/* 1, list,保持一致;有效
2,实体bean,保持一致,有效
3, string,未保持一致,无效
4, int ,未保持一致,无效*/
public class Test {
public static void begin() {
ArrayList arrayList=new ArrayList();
arrayList.add("1");
String aString="sfasdf";
int aint=1;
Demo bean=new Demo();
bean.setName("demo1");
two(arrayList,bean,aString,aint);
System.out.println(arrayList.size()+"--"+ bean.getName()+"--"+aString+"--"+aint);
}
public static void two(ArrayList arrayList,Demo bean,String aString,int aint) {
aString="string2";
arrayList.add("12323");
bean.setName("demo2");
aint=2;
System.out.println(arrayList.size()+"--"+bean.getName()+"--"+aString+"--"+aint);
}
public static void main(String[] args) {
begin();
}
}
public class Demo {
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
private String name;
}