In Java, equals and Array.equals

Asked 2 years ago, Updated 2 years ago, 115 views

What are the two differences when comparing arrays in Java?

array1.equals(array2);
Arrays.equals(array1, array2);

array java

2022-09-22 22:10

1 Answers

array1.equals(array2) is equal to array1 == array2. What I mean by that is to compare two arrays of the same object.

Arrays.equals (array1, array2) compare the contents of the two arrays to be the same.


2022-09-22 22:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.