I have this compilation error when I write the following code
Boolean[] booleans = new Boolean[]{true, false, false};
String[] strings = new String[]{"hello", "world"};
Integer[] integers = new Integer[]{1, 2, 3, 4};
// When the above instances are cast to Object[], it all works fine
Object[] booleansObj = (Object[])booleans;
Object[] stringsObj = (Object[])strings;
Object[] integersObj = (Object[])integers;
// When the above instances are cast to List<T>. String and Integer still
// works, but not for Boolean
List<String> stringsList = (List<String>)strings;
List<Integer> integersList = (List<Integer>)integers;
// this will have Cannot cast from Boolean[] to List<Boolean> error
List<Boolean> booleansList = (List<Boolean>)booleans;
My question is why Boolean[] can not cast to List?