package shuzu_practice;
public class Practice2 {
/*
需求2:
定义方法,判断两个int数组的内容是否相同
数组相同: 长度必须相同,同一个索引对应的元素值必须相同
不允许使用集合
*/
public static void main(String[] args) {
boolean a = false;
boolean b = false;
int[] arr1 = {10, 20, 30, 40, 50};
int[] arr2 = {10, 20, 30, 40};
if (arr1.length == arr2.length) {
b = true;
}
int temp1 = 0;
int temp2 = 0;
for (int i = 0; i < arr1.length; i++) {
temp1 = arr1[i];
}
for (int j = 0; j < arr2.length; j++) {
temp2 = arr2[j];
}
if (temp1 == temp2) {
a = true;
}
if (a && b) {
System.out.println("数组相同");
} else {
System.out.println("数组不相同");
}
}
}