I\'ve been learning about HashMaps recently but I have one question that I can\'t seem to get a clear answer on. The main difference between -
HashMap hash1
- Generics can be implied to classes, interfaces, methods, variables etc.. but the most important reason for which its used is making the Collection more type safe.
- Generics make sure that only specific type of object enters and comes out of the Collections.
- Moreover its worth mentioning that there is a process known as Erasure,
-> Erasure is a process where the type parameters and type arguments are removed from the generic classes and interfaces by the compiler, making it back compatible with the codes that where written without Generics.
So,
HashMap
becomes of Raw type,
HashMap map = new HashMap();