Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3.  
  4. /**
  5. * Created by janusz on 08.12.16.
  6. */
  7. public class Main {
  8.  
  9. class Egg {
  10. boolean isFresh;
  11.  
  12. public boolean isFresh() {
  13. return isFresh;
  14. }
  15. }
  16.  
  17. public static boolean allEggsAreFresh(List<Egg> eggs){
  18. return eggs.stream().allMatch(egg -> egg.isFresh());
  19. }
  20.  
  21. public static boolean anyEggIsFresh(List<Egg> eggs){
  22. return eggs.stream().anyMatch(egg -> egg.isFresh());
  23. }
  24.  
  25. public static void main(String[] args) {
  26.  
  27. List<Egg> eggs = new ArrayList<>();
  28.  
  29. System.out.println(allEggsAreFresh(eggs));
  30. System.out.println(anyEggIsFresh(eggs));
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement