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

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -