Type a variable declared as the interface type, assigned an implementation
Type a variable declared as the interface type, assigned an implementation
Answer
List<String> names = new ArrayList<>(); Set<Integer> ids = new HashSet<>(); Map<String, Integer> scores = new HashMap<>();
Declare the variable as the interface (List, Set, Map) and assign a concrete class. This is the canonical collections idiom.