package com.company;
public class test01 {
//定义一个方法,用于比较两个数组的内容是否相等
/*
* 两个明确:
* 返回值类型:boolean
* 参数:int[] arr,int[] arr2
*/
public static void main(String[] args) {
int arr1[]={11,22,33,44,55};
int arr2[]={11,22,33,44,55};
boolean aa=Equal(arr1,arr2);
if (aa==true){
System.out.println("这两个数组内容一样");
}else{
System.out.println("这两个数组内容不一样");
}
}
public static boolean Equal(int arr1[],int arr2[]){
if (arr1.length!= arr2.length){
return false;
}
for (int i = 0; i < arr1.length ; i++) {
if (arr1[i]!=arr2[i]) {
return false;
}
}
return true;
}
}
11-10
2039
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-27
288
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-21
4601
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)