-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: hbelmiro <helber.belmiro@gmail.com>
- Loading branch information
Showing
2 changed files
with
10 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 9 additions & 8 deletions
17
days/day028/src/main/java/com/thegreatapi/ahundreddaysofjava/day028/Day028.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
package com.thegreatapi.ahundreddaysofjava.day028; | ||
|
||
import java.util.Arrays; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
public class Day028 { | ||
import static java.util.Comparator.comparing; | ||
|
||
public final class Day028 { | ||
|
||
public static void main(String[] args) { | ||
Player messi = new Player("Lionel Messi", "Barcelona", "Argentina", 42); | ||
Player cr7 = new Player("Cristiano Ronaldo", "Juventus", "Portugal", 50); | ||
Player neymar = new Player("Neymar Jr.", "PSG", "Brazil", 41); | ||
var messi = new Player("Lionel Messi", "PSG", "Argentina", 42); | ||
var cr7 = new Player("Cristiano Ronaldo", "Manchester United", "Portugal", 50); | ||
var lukaku = new Player("Romelu Lukaku", "Chelsea", "Belgium", 41); | ||
|
||
List<Player> players = Arrays.asList(messi, cr7, neymar); | ||
List<Player> players = Arrays.asList(messi, cr7, lukaku); | ||
|
||
players.sort(Comparator.comparing(Player::numberOfGoals).reversed()); | ||
players.sort(comparing(Player::numberOfGoals).reversed()); | ||
|
||
System.out.println("Top Scorers:"); | ||
players.forEach(System.out::println); | ||
} | ||
|
||
private record Player(String name, String club, String coutry, int numberOfGoals) { | ||
private record Player(String name, String club, String country, int numberOfGoals) { | ||
} | ||
} |