我正在尝试调试使用Lambda Expression的简单Java应用程序。我无法使用普通的Eclipse调试器调试Lambda Expression。
答案 0 :(得分:1)
这个答案很晚,但是希望它对某人有用。 我使用的是https://stackoverflow.com/a/24542150/10605477,但是有时当代码有点混乱或无法获取数据时,我会破坏代码并插入窥视。
protected Optional<Name> get(String username) {
return profileDao.getProfiles()
.stream()
.filter(profile ->
profile.getUserName().equals(username))
.peek(data -> System.out.println(data))
.findFirst();
}
答案 1 :(得分:0)
您可以将表达式转换为语句。
List<String> list = new ArrayList<>();
// expression
boolean allMatch1 = list.stream().allMatch(s -> s.contains("Hello"));
// statement
boolean allMatch2 = list.stream().allMatch(s -> {
return s.contains("Hello");
});
您现在可以在return s.contains("Hello");
行