6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Arrays.asList(int[]).contains(int) がうまく動かない

Posted at

int[] で宣言した 配列を Arrays.asList に渡して contains したけど思った動作にならない。

int[] array = {1, 2, 3, 4, 5};
Arrays.asList(array).contains(3)
-> false

いろいろ探したけど、int[] ではなく Integer[] で配列を宣言すると思った動作になる。

Integer[] array = {1, 2, 3, 4, 5};
Arrays.asList(array).contains(3)
-> true
6
6
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?