Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- /**
- * Created by janusz on 08.12.16.
- */
- public class Main {
- class Egg {
- boolean isFresh;
- public boolean isFresh() {
- return isFresh;
- }
- }
- public static boolean allEggsAreFresh(List<Egg> eggs){
- return eggs.stream().allMatch(egg -> egg.isFresh());
- }
- public static boolean anyEggIsFresh(List<Egg> eggs){
- return eggs.stream().anyMatch(egg -> egg.isFresh());
- }
- public static void main(String[] args) {
- List<Egg> eggs = new ArrayList<>();
- System.out.println(allEggsAreFresh(eggs));
- System.out.println(anyEggIsFresh(eggs));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement