Difficulty with Generic Wildcarding
I don't seem to be able to have a List which can contain two different kinds of objects (List would either be all Object A or all Object B, never a combination of both). On the below code, the compiler (Eclipse...) gives the error:
The method add(capture-of ?) in the type List<capture-of ?> is not applicable for the arguments
(Integer)
List<?> versions =null;
try{//Try and catch here still, but I changed object types such that it is useless
ArrayList<String> test =new ArrayList<String>();
test.add("test");
versions = test;//works
}catch ( Exception e ){
Integer test = 0;
versions =new ArrayList<Integer>();
versions.add(test);// compiler error
}
If I don't use the generic parameterization, the code works fine and the compiler just give me a warning. Any ideas?

