Created
November 26, 2019 08:00
-
-
Save hongbeomi/0a0ea47b986d7abe01e1e81a5b70db7d to your computer and use it in GitHub Desktop.
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
// filterApples 메서드의 동작을 직접 파라미터화 했다. | |
List<Apple> redApples = filterApples(inventory, new ApplePredicate() { | |
public boolean test(Apple apple){ | |
return RED.equals(apple.getColor()); | |
} | |
}); | |
// 이벤트 핸들러 객체를 구현하는 익명 클래스 | |
button.setOnAction(new EventHandler<ActionEvent>() { | |
public void handle(ActionEvent event) { | |
System.out.println("Whoooo a click!!"); | |
} | |
}); | |
// 아래 2개의 코드는 반복되어 지저분한 코드... | |
List<Apple> redApples = filterApples(inventory, new ApplePredicate() { | |
public boolean test(Apple a){ | |
return RED.equals(a.getColor()); | |
} | |
}); | |
button.setOnAction(new EventHandler<ActionEvent>() { | |
public void handle(ActionEvent event) { | |
System.out.println("Whoooo a click!!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment