Hi!
I'd like to use a generic list, but the initialization method only returns a List
.
The following code works well:
List tmpColumnList = aMethodToInitializeTheColumnList();
tmpColumnList.add("ANICELITTLECOLUMN");
Java accuses that I'm using a raw type and I should paramerize the list. So I added the question mark parameterize this list.
List<?> tmpColumnList = aMethodToInitializeTheColumnList();
tmpColumnList.add("ANICELITTLECOLUMN");
Problem is: Now the add(..)
method doesn't work anymore.
I cannot assure that the list only contains String
s as aMethodToInitializeTheColumnList()
is not implemented in my code.
What is my mistake?
Thanks!