Skip to content

Instantly share code, notes, and snippets.

@hongbeomi
Created November 26, 2019 07:57
Show Gist options
  • Save hongbeomi/66d042b526fa179e219b168e8a8530d2 to your computer and use it in GitHub Desktop.
Save hongbeomi/66d042b526fa179e219b168e8a8530d2 to your computer and use it in GitHub Desktop.
enum Color { RED, GREEN }
public static List<Apple> filterGreenApples(List<Apple> inventory) {
List<Apple> result = new ArrayList<>(); // 사과 누적 리스트
for(Apple apple: inventory){
if( GREEN.equals(apple.getColor())) { // 녹색 사과만 선택
result.add(apple);
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment