today we talked about advantages of Java 7 in our company. Since Java 7 there is the possibility to define following line
Map<String, List<String>> myMap = new HashMap<String, List<String>>();
as
Map<String, List<String>> myMap = new HashMap<>();
We had a long discussion about the topic described above. Some of us had the opinion that this is type inference (like var
keyword in C#) and the type will be computed at runtime, others thought it's only a simpler way to declare some variable and there is no inference, because the type of is known by the context at compile time.
Please provide clarification. How dows the technique work?
EDIT: Official Oracle Documentation provides no precise documentation about that. http://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html