undefined behavior - Java list.contains returning false, should be true -


this question has answer here:

okay, trying conditional checks , noticed returned false.... i'm missing?

int test = 1;  int[] testing= {1,3};  system.out.println(arrays.aslist(testing).contains(test) );  //false??? 

arrays.aslist generic method generic type variable used in vararg parameter. primitive types don't work generics.

therefore, after

arrays.aslist(testing) 

the list returned contains single element, array of type int.

your test pass if testing declared integer[].


Comments

Popular posts from this blog

android - Inheriting from Theme.AppCompat* -

broadcastreceiver - android BOOT_COMPLETED not received if not activity intent-filter -

basic authentication with http post params android -