What is the diamond operator in Java? [duplicate]

Don’t worry. It’s not an evil. It’s feature of Java 7. The purpose of the diamond operator is to simplify instantiation of generic classes. For example, instead of List<Map<Integer,Set<String>>> p = new ArrayList<Map<Integer,Set<String>>>(); with the diamond operator we can write only List<Map<Integer,Set<String>>> p = new ArrayList<>(); If you want to know more about it and … Read more