Java 7 -> Cannot infer Type with Comparator
问题 When I use java 7 to compile a code using PriorityQueue with Comparator, compiler sends error: cannot infer type arguments for Comparator<T>; Comparator<Map.Entry<Double, PureColor>> colorComparator = new Comparator<>() { ^ reason: cannot use '<>' with anonymous inner classes Why this, and how can I compile me code: Comparator<Map.Entry<Double, PureColor>> colorComparator = new Comparator<Map.Entry<Double, PureColor>>() { @Override public int compare(Map.Entry<Double, PureColor> o1, Map.Entry