Why does conversion from collection of Integers to collection of String work but it fails when I actually has to convert the Integer to String? Why dosent it fail/catch it earlier? In my example below
static <T extends List<?> >
void testConversion(T... args)
{
**// Didnt catch here?**
List<String>[] slarray = (List<String>[])args;
System.out.printf("Value is %s\n", slarray[0].get(0));
**// Didnt catch here?**
List<String> slist = (List<String>)args[0];
// FAIL runtime exception
String s2 = slist.get(0);
// FAIL exception
String s = slarray[0].get(0);
}
public static void main( String[] args )
{
testConversion(Arrays.asList(11,12), Arrays.asList(21,22));
}