public static void main(String[] args) {
System.out.println(Objects.equals(null, null));
System.out.println(Objects.equals(null, ""));
System.out.println(Objects.equals("", ""));
System.out.println(Objects.equals(1, 1));
System.out.println(Objects.equals(1, 2));
System.out.println(Objects.equals("a", "b"));
System.out.println(Objects.equals("a1", "a1"));
String[] str1 = {"a","b","c"};
String[] str2 = {"a1","b","c"};
System.out.println(Arrays.equals(str1, str2));
String[] str3 = null;
System.out.println(Arrays.equals(str1, str3));
System.out.println(Arrays.equals(str3, str3));
String[] str4 = new String[3];
System.out.println(Arrays.equals(str1, str4));
System.out.println(Arrays.equals(str4, str4));
String[] str5 = {"a","b","c"};
System.out.println(Arrays.equals(str1, str5));
List<Integer> list1 = new ArrayList<>();
List<Integer> list2 = new ArrayList<>();
System.out.println(list1.equals(list2));
list1.add(1);
list2.add(1);
System.out.println(list1.equals(list2));
list2.add(2);
System.out.println(list1.equals(list2));
list1 = null;
System.out.println(list2.equals(list1));
System.out.println(list1.equals(list1));
System.out.println(list1.equals(list2));
List<Integer> list11 = new ArrayList<>();
List<Integer> list22 = new ArrayList<>();
System.out.println(list11.containsAll(list22));
list11.add(1);
list22 .add(1);
System.out.println(list11.containsAll(list22));
list22 .add(2);
System.out.println(list11.containsAll(list22));
list11= null;
System.out.println(list22 .containsAll(list11));
System.out.println(list11.containsAll(list11));
System.out.println(list11.containsAll(list22));
}
- 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
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59