Type a List<String> with the diamond operator
Type a List<String> with the diamond operator
Answer
List<String> names = new ArrayList<>();
The diamond <> tells the compiler to infer the type argument from the left-hand side declaration. No cast needed when you call names.get(i).