>  Q&A  >  본문

Java中List的contains方法为什么不能实现二维数组中的去重?

请教为什么以下代码会返回false?

        List list = new ArrayList();
        int[][] arr = {{-1, -1, 2}, {-1, 0, 1}};
        list.add(arr[0]);
        list.add(arr[1]);
        int[] temp = {-1, 0, 1};
        return list.contains(temp);

当list中的元素是数组时,如何实现去重?谢谢回答

迷茫迷茫2744일 전869

모든 응답(1)나는 대답할 것이다

  • PHP中文网

    PHP中文网2017-04-18 10:50:06

    같음은 내부적으로 사용됩니다

    으아악

    다시 작성하여 모든 요소를 ​​비교할 수 있습니다

    회신하다
    0
  • 취소회신하다