我听说lambdas即将到达你附近的Java(J8).我在一些博客上找到了一个例子:
SoccerService soccerService = (teamA, teamB) -> {
SoccerResult result = null;
if (teamA == teamB) {
result = SoccerResult.DRAW;
}
else if(teamA < teamB) {
result = SoccerResult.LOST;
}
else {
result = SoccerResult.WON;
}
return result;
};
Run Code Online (Sandbox Code Playgroud)
所以马上就开始了:
teamA和teamB类型?或者不是它们(就像一些奇怪的泛型)?