In this blog post, we will look at some of the proverbial operations on a list data structure and make some comparisons between Java 8/9 and the Groovy syntax. First let's talke about the data structure. Think of it as just a simple Rugby player who has name and a rating.
Java
class RugbyPlayer {
private String name;
private Integer rating;
RugbyPlayer(String name, Integer rating) {
this.name = name;
this.rating = rating;
}
public String toString() {
return name + "," + rating;
}
public String getName() {
return name;
}
public Integer getRating() {
return rating;
}
}
//...
//...
List<RugbyPlayer> players = Arrays.asList(
new RugbyPlayer("Tadgh Furlong", 9),
new RugbyPlayer("Bundee AKi", 7),
new RugbyPlayer("Rory Best", 8),
new RugbyPlayer("Jacob StockDale", 8)
);
from DZone.com Feed https://ift.tt/2AwKoQ3
No comments:
Post a Comment