+ 27
Why using Raw types in java is not recommended?
Actually I get a warning when I use them. for example: List a = new ArrayList();
4 Answers
+ 5
It's considered unsafe because literally any object can go in there, which can result in unexpected behavior to say the least, but since getting any object could be what you want, that's the reason why it's just a warning. Consider that you could specify the type of object you want, so that no one can provide anything outside that object, avoiding potential security issues as well. Hope this is answers Amir.
+ 6
Exactly as Roberto said. On the top of that i would ask: "why they have created generics?". :) think about it. Your question is basically before Java 5. Perfect answer would be to copy one page from DocsOracle, one about raw type itself.
+ 2
This sounds like an arraylist defaulting into E which is the generic object type when it is not assigned to a type/class. Arrays are suppose to be defined such as STRING etc. When not defined anyone can put anything in/out and compromise the script.
- 1
Hy