Why can't Java 7 diamond operator be used with anonymous classes?
Consider this Java code which attempts to instantiate some List s: List<String> list1 = new ArrayList<String>(); List<String> list2 = new ArrayList<>(); List<String> list3 = new ArrayList<String>() { }; List<String> list4 = new ArrayList<>() { }; List<String> list5 = new ArrayList<Integer>() { }; list1 and list2 are straightforward; list2 uses the new diamond operator in Java 7 to reduce unnecessary repetition of the type parameters. list3 is a variation on list1 using an anonymous class, potentially to override some methods of ArrayList . list4 attempts to use the diamond operator, similar to