In Page 112 of CHAPTER 5 GENERICS in the book - Effective Java
, these sentences appears
Just what is the difference between the raw type List
and the
parameterized type List<Object>
...While you can pass a List<String>
to a parameter of type List, you can’t pass it to a parameter of type
List<Object>
I tried this
public static void getMeListOfObjs(List<Object> al){
System.out.println(al.get(0));
}
public static void main(String[] args) {
List<Object> al = new ArrayList<Object>();
String mys1 = "jon";
al.add(mys1);
getMeListOfObjs(al);
}
It runs without any error... Was that an error in book content? I am quoting from the second edition