在 java 8 中使用 lambda 表达式有哪些优势?
Interface AccountService{
public void createAccount();
}
AccountService accountServiceAnonymous = new AccountService(){
public void createAccount(){
Account account = new Account();
save(account);
}
};
AccountService accountServiceLambda = () -> {
Account account = new Account();
save(account);
}
除了减少代码行数之外,在java 8中使用lambda表达式还有其他优点吗?