关于list
list是引用传递?具个例子:
import java.util.ArrayList;
import java.util.List;
public class AboutList {
private List<String> aList_;
public void setList () {
List<String> aList = new ArrayList<String>();
aList_ = aList;
}
public List<String> getList () {
return aList_;
}
public static void main(String[] args) {
AboutList aboutList = new AboutList();
aboutList.setList();
List<String> anotherList = aboutList.getList();
String id = "a,b,c,d,e";
id = id.trim();
anotherList.clear();
if ( id.indexOf(",") < 0 ) {
anotherList.add(id);
} else {
String[] IdArrs = id.split(",");
for ( int i = 0; IdArrs != null && i < IdArrs.length; i++ ) {
anotherList.add(IdArrs[i].trim());
}
}
System.out.println("aList: " + aboutList.getList());
}
}
运行结果为:
aList: [a, b, c, d, e]
表明list是引用传递,那我想问一下,除了list,还有什么数据类型是引用传递?