Lists do not contain primitives, so Arrays.asList (int []) will create a List with one entry of type int[] .
This code works:
static Integer[] numbers = {813, 907, 908, 909, 910}; public static void main(String[] args) { Integer number = 907; boolean b = Arrays.asList(numbers).contains(number); System.out.println(b);
For your question, what will Arrays.asList(numbers) contain as long as it is int[] :
This code:
static int[] numbers = {813, 907, 908, 909, 910}; public static void main(String[] args) { int number = 907; List<int[]> list = Arrays.asList(numbers); boolean b = list.contains(number); System.out.println(b);
has the following result:
false list: [[ I@da89a7 ] content: [813, 907, 908, 909, 910]
As you can see, List contains one element of type int[] ( [[I indicates int[] ). He has elements that were originally created.
source share