lambda comparator java code example
Example 1: lambda comparator java
Comparator byName =
(Developer o1, Developer o2)->o1.getName().compareTo(o2.getName());
Example 2: java 8 lambda comparator
Comparator byName = new Comparator() {
@Override
public int compare(Developer o1, Developer o2) {
return o1.getName().compareTo(o2.getName());
}
};