java中判断一个数是否在数组中
原创
©著作权归作者所有:来自51CTO博客作者wx62e9cee37942d的原创作品,请联系作者获取转载授权,否则将追究法律责任
List<Object[]> rows = new java.util.ArrayList<Object[]>();
String a[]={"a1","a2"};
String b[]={"b1","b3"};
String b1[]={"bd1","bdd3"};
String b2[]={"b2","a3"};
String c[]={"a3","a2d"};
rows.add(a);
rows.add(b);
rows.add(b2);
rows.add(b1);
for (int i = 0; i < rows.size(); i++) {
boolean flag=true;
for (int j = 0; j < c.length; j++) {
if(rows.get(i)[1].equals(c[j])){
System.out.println("存在该数字!");
flag=false;
break;
}
}
if(flag){
System.out.println("不存在该数字!");
System.out.println(i);
//rows.remove(i);
}
}
System.out.println("----------------");
int index[]={0,1,3};
for (int i = 0; i < index.length; i++) {
rows.remove(0);
}
for (int i = 0; i < rows.size(); i++) {
System.out.println(rows.get(i)[0]+" "+rows.get(i)[1]);
}