I am using a generics wildcard for my class and also using the wildcard of list in one of my methods:
public class Example<E> {
private E element;
private ArrayList<String> createNewList() {
return new ArrayList<>();
}
}
when i try to use the Method:
List<String> myList = new Example().createNewList();
tells me when compiling with Xlint:unchecked
unchecked conversion
required: List<String>
found: ArrayList
since my E-Type has nothing to do with the my createNewLists Generics < String>, why it tells me i dont have the required Type?
thanks in advance.
by the way - using:
List<String> myList = new Example<>().createNewList();
works perfectly fine. but why?