Java Generics and Raw Types
问题 I have the next code: ArrayList value = new ArrayList<Integer>(); // 1 value.add("Test"); // 2 I'm trying to understand line 2. Although I can see that value.add("Test"); compiles without errors, I can't see the reason it doesn't throw a runtime exception. If value is referencing a generic ArrayList object, why Java allows to add a String to it? Can anyone explain it to me? The closest explanation I've found about this is described here, but I still don't understand the core reason: Stack s =