1. Java 8 Comparators example added
2. Comparator.comparing example added
This commit is contained in:
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
public class PlayerSorter {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
List<Player> footballTeam = new ArrayList<Player>();
|
||||
Player player1 = new Player(59, "John", 20);
|
||||
Player player2 = new Player(67, "Roger", 22);
|
||||
@@ -15,11 +15,11 @@ public class PlayerSorter {
|
||||
footballTeam.add(player1);
|
||||
footballTeam.add(player2);
|
||||
footballTeam.add(player3);
|
||||
|
||||
|
||||
System.out.println("Before Sorting : " + footballTeam);
|
||||
Collections.sort(footballTeam);
|
||||
System.out.println("After Sorting : " + footballTeam);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user