There is a code in Java:
import java.util.HashMap;
import java.util.Collection;
import java.util.Map;
public class Main {
public static void main(String[] args) {
Map<Integer, String> langMap = new HashMap<>();
langMap.put(1, "Java");
langMap.put(2, "C#");
Collection<String> values = langMap.values();
}
}
In the last code line there is Collection<String>
. Isn't <String>
unnecessary because the type is assumed based on the values assigned from langMap?