Here's a little code of my own I was experimenting with, based on the WhizLabs simulator:
import java.util.*;
class
Test {
public static void main(
String[] args ) {
Object[] array = {1,2,3,4,5};
List<? extends Object> list = new ArrayList(Arrays.asList()); // line A
// List<? extends Object> list = Arrays.asList(); // line B
list.add(null);
System.out.println(list);
}
}
Question: Why does line A work, but if you comment out line A and put in line B, a runtime exception unsupported operation occurs??
[ January 26, 2007: Message edited by: jan ter avest ]