????4.??????????ù????????????
????Java 8??????????Stream API ???ü????е???????????????????????????????????
??????????????????????20???????????????9????????????Щ??????????
????final BigDecimal totalOfDiscountedPrices = prices.stream()
????.filter(price -> price.compareTo(BigDecimal.valueOf(20)) > 0)
????.map(price -> price.multiply(BigDecimal.valueOf(0.9)))
????.reduce(BigDecimal.ZERO??BigDecimal::add);


????System.out.println("Total of discounted prices: " + totalOfDiscountedPrices);
??????????£?????????????????Щ?????????????У????????????????????????м??????
????????Stream API???????????????????д?????? ??
????Lambda??????
????Oracle?????????????Sergey Kuksenko???????????????????? JDK 8: Lambda Performance study?? ?????????????lambda??????????????????????????????????? 16???????capture?????inner class????? non-capture????????inner class??5????
????lambda???????????ppt?? ???????????lambda??????(????capture???capture?????)????????lambda???????????????????? ??????????á?
????Java 8 Lambdas – they are fast?? very fast???????? (??????)??????lambda??????????
????Lambda????????
??????涼???Lambda??θ??Java???????????????Lambda?????????????
????JVM????????κ??????д???????????????????????????????????OO?????????????Java?????????ζ??Java?????????????????????????????
???????????????Java??????????????Scala????????????????????????????????????????????????????? ????????????????JVM????????????????????????????С?
???????????????Java 6/7?е?????????????????
// simple check against empty strings
public static int check(String s) {
if (s.equals("")) {
throw new IllegalArgumentException();
}
return s.length();
}

//map names to lengths

List lengths = new ArrayList();

for (String name : Arrays.asList(args)) {
lengths.add(check(name));
}
????????????????????????δ????????????????????£?
????at LmbdaMain.check(LmbdaMain.java:19)
????at LmbdaMain.main(LmbdaMain.java:34)
?????????Lambda??????
Stream lengths = names.stream().map(name -> check(name));

at LmbdaMain.check(LmbdaMain.java:19)
at LmbdaMain.lambda$0(LmbdaMain.java:37)
at LmbdaMain$$Lambda$1/821270929.apply(Unknown Source)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.LongPipeline.reduce(LongPipeline.java:438)
at java.util.stream.LongPipeline.sum(LongPipeline.java:396)
at java.util.stream.ReferencePipeline.count(ReferencePipeline.java:526)
at LmbdaMain.main(LmbdaMain.java:39)
????????????Scala?????????????????????????????????????????????????ζ????????????
????????????????????Lambda??
???????
??????Java???????棬??????????????????????????????????????????????????????????????????????????????г??????????????????????г???????????У????????????棬??????????????????????????????????
?????????μ???????????????????????????????д??????????????????Щ??????????????????????????????????????д????????????????——???????????????????????????????????????????????????????????????????????????????
??????д????????????????????????????????????????????????????????????????????????????????????????????????????????д??????????????????????????????????????????????
????????????Java?????????????