forked from janbodnar/Java-Advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComparingArrays.java
More file actions
42 lines (28 loc) · 844 Bytes
/
ComparingArrays.java
File metadata and controls
42 lines (28 loc) · 844 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.zetcode;
import java.util.Arrays;
public class ComparingArrays {
public static void main(String[] args) {
int[] a = {1, 1, 2, 1, 1};
int[] b = {0, 0, 3, 0, 0};
int[][] c = {
{1, 1, 2, 1, 1},
{0, 0, 3, 0, 0}
};
int[][] d = {
a,
b
};
System.out.print("equals() method: ");
if (Arrays.equals(c, d)) {
System.out.println("Arrays c, d are equal");
} else {
System.out.println("Arrays c, d are not equal");
}
System.out.print("deepEquals() method: ");
if (Arrays.deepEquals(c, d)) {
System.out.println("Arrays c, d are equal");
} else {
System.out.println("Arrays c, d are not equal");
}
}
}