这是我写的一段代码:
import java.util.*;public class test{
    public static void main(String[] args){
String type = "aaa";
String name = "sss";

String[] conds = new String[2];
conds[0] = type;
conds[1] = name; ArrayList<String[]> list = new ArrayList<String[]>();
list.add(conds); type = "pp";
name = "mm";

conds[0] = type;
conds[1] = name;

list.add(conds); for(int m = 0; m < list.size(); m++){     String[] tmp =  new String[2];
    tmp = list.get(m);
    System.out.println("type: " + tmp[0]);
    System.out.println("name: " + tmp[1]);
}//end for
    }//end main
}运行结果是
pp
mm
pp
mm
而不是想要的:
aaa
sss
pp
mm
我估计是因为list.add(conds)时加入ArrayList的仅仅是conds这一变量,而并没有将此时conds指向的字符串数组加入ArrayList。
那么我需要怎么做才能将实际的String[]加入到ArrayList中呢?
希望大家帮忙,谢谢