This discussion is archived
4 Replies Latest reply: Sep 22, 2010 10:40 PM by EJP RSS

Problem with adding a new element to the list

843793 Newbie
Currently Being Moderated
import java.util.Arrays;
import java.util.List;

public class Test {

public static void main(String[] args)
List<Object> objs = Arrays.<Object>asList(1,"two");
List<? super Integer> ints = objs;

ints has been declared with type super. So I should be able to add elements to the list ints. But I'm getting the following runtime exception

Exception in thread "main" java.lang.UnsupportedOperationException
at java.util.AbstractList.add(Unknown Source)
at java.util.AbstractList.add(Unknown Source)
at p1.Test.main(