- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArrayEqualExample.java
More file actions
Latest commit
26 lines (24 loc) · 782 Bytes
/
Copy pathArrayEqualExample.java
File metadata and controls
26 lines (24 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
packagecom.codinginterview;
importjava.util.Arrays;
publicclassArrayEqualExample {
publicstaticvoidmain(String[] args) {
System.out.println("Array Equal Example");
int[] a = {1,2,3,4,5};
int[] b = {1,2,3,4,5};
int[] c = {2,3};
System.out.println("Are arrays equal-1 ::"+arrayEqual1(a, b));
System.out.println("Are arrays equal-2 ::"+arrayEqual2(c, b));
}
privatestaticbooleanarrayEqual1(int [] a, int [] b){
returnArrays.equals(a, b);
}
privatestaticbooleanarrayEqual2(int [] a, int [] b){
if(a.length != b.length)
returnfalse;
for(inti = 0; i < a.length; i++){
if(a[i] != b[i])
returnfalse;
}
returntrue;
}
}