Java 8 New Features by Richard Reese

Java 8 New Features by Richard Reese

Author:Richard Reese [Reese, Richard]
Language: eng
Format: epub
Tags: Computers and Internet: Java
Publisher: P8tech
Published: 2014-07-14T16:00:00+00:00


Below, a stream is created based on the partsList and is used with a combination of predicate lambda expressions. While the example seems to execute these methods one after another, remember that a stream cannot be reused. To make this example work, the stream has to be recreated before each execution of a match method.

Stream<Part> partsStream = partsList.stream();

System.out.println(partsStream.

allMatch(p -> p.getQuantity()<50));

System.out.println(partsStream.

anyMatch(p -> p.getQuantity()<50));

System.out.println(partsStream.

noneMatch(p -> p.getQuantity()<50));

System.out.println(partsStream.

allMatch(p -> p.getWeight()>50));

System.out.println(partsStream.

anyMatch(p -> p.getQuantity()>1000));

System.out.println(partsStream.

noneMatch(p -> p.getPrice()>.35f));



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.