I am trying understand the following code snippet, searched links on stackoverflow with regards to lowerbound and upperbound
Just trying to get over the confusion in the following line ,
si=s//OK why? arrays of objects can be implicitly casted to arrays of integers?
List<? extends Number> l = new ArrayList<>();
List<? extends Integer> i = new ArrayList<>();
l = i;//OK i is a subtype of l
List<? super Number> s = new ArrayList<>();
List<? super Integer> si = new ArrayList<>();
si = new ArrayList<Integer>();//OK understand integer matches the pattern of ? super Integer
s = new ArrayList<Object>();//OK understand that object is superclass of Number
si=s//OK why? arrays of objects can be implicitly casted to arrays of integers?
//consider this
List<Integer> integers = new ArrayList<Integer>();
List<Object> objects = new ArrayList<Object>();
integers = objects; //NOT OK Type mismatch: cannot convert from List<Object> to List<Integer>
//consider this
Integer ten = 10; //integer ten
Object none = new Object();//some none
ten = none;//NOT OK none cannot be implicitly casted to ten
Any help is appreciated