Java: Raw Types vs. Generics [duplicate]
问题 This question already has answers here : What is a raw type and why shouldn't we use it? (15 answers) Closed 2 years ago . Consider the sample code below /* The new Java 5 or later Generic code */ class TestInserter { public static void main(String[] ar) { List<Integer> myList = new ArrayList<Integer>(); myList.add(20); myList.add(42); Inserter ins = new Inserter(); ins.insert(myList); } } /* Legacy Code */ class Inserter { public void insert(List list) { list.add(new Integer(55)); } }