java判断数组相等的方法
public class Tools {
public static boolean arrayEquals(String[] a,String[] b){
boolean flag = false;
if(a.length != b.length){
return false;
}else{
for (int i = 0; i < a.length; i++) {
System.out.println(a[i] + "\t" + b[i]);
if(!a[i].equals(b[i])){
flag = false;
break;
}else{
flag = true;
}
}
}
return flag;
}
public static void main(String[] args) {
String[] a={"1","2","3","3"};
String[] b={"1","2","3","3"};
String[] c={"1","3","3","2"};
System.out.println(arrayEquals(a,b));
System.out.println(arrayEquals(a,c));
}
}
补充:软件开发 , Java ,