I get "Unchecked assignment: java.util.List to java.util.List<java.lang.Integer>" at the line with the comment.
The warning is cleared when the GetList parameter is changed to GetList<?>.
I don't understand why the GetList generic type would influence the outcome of getIntegerList(). Tried in both Intellij Idea and Eclipse. Is it normal or is the warning message wrong?
import java.util.ArrayList;
import java.util.List;
public class GetList<T> {
private final List<Integer> integerList= new ArrayList<Integer>();
public List<Integer> getIntegerList() {
return integerList;
}
}
import java.util.List;
public class Main {
public Main(GetList getList) {
List<Integer> rahan = getList.getIntegerList(); //this line shows the warning above
}
}