java中的双层for循环只循环外面的for,里面的for不循环,如果要让里面液循环怎么做?
publicstaticvoidListTest(){String[]a={"A","B","C"};String[]b={};List<String>list_a=Ar...
public static void ListTest(){
String[] a = {"A","B","C"};
String[] b = {};
List<String> list_a = Arrays.asList(a);
List<String> list_b = Arrays.asList(b);
for(int i = 0; i < list_a.size(); i++){
String x = list_a.get(i).trim().toString();
for(int j = 0; j < list_b.size(); j++){
String y = list_b.get(j).trim().toString();
if(!x.equals(y)){
list_b.add(x);
}
}
}
} 展开
String[] a = {"A","B","C"};
String[] b = {};
List<String> list_a = Arrays.asList(a);
List<String> list_b = Arrays.asList(b);
for(int i = 0; i < list_a.size(); i++){
String x = list_a.get(i).trim().toString();
for(int j = 0; j < list_b.size(); j++){
String y = list_b.get(j).trim().toString();
if(!x.equals(y)){
list_b.add(x);
}
}
}
} 展开
11个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询