Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of these statements about what Arrays.equals compares for a nested array is correct?

  • A.Its elements recursively.
  • B.Only the lengths of the two outer arrays.
  • C.Nothing; it throws IllegalArgumentException for an array of arrays.
  • D.Its elements with their own equals.

Answer: D

Arrays.equals walks one level and uses each element's equals, and an array does not override equals, so two distinct inner arrays holding the same values are unequal. Arrays.deepEquals is the recursive version, just as deepToString is the readable counterpart of toString.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.