JAVA 8 LAMBDA Expressions AND Stream API - EXAMPLES
JAVA LAMBDA nədir? Necə istifadə olunur? Examples : https://dzone.com/articles/java-stream-api Simple sintax: a -> a.canHop() (Animal a) -> { return a.canHop(); } // blok iceriinde yazilanda return ve noqeteli vergul de olmalidi (a, b) -> { int a = 0; return 5;} // DOES NOT COMPILE // Cunki declare olunmus deyiskeni yeniden tanimlamaga qoymur A boolean expression : (List<String> list) -> list.isEmpty() Creating objects : () -> new Apple(10) Consuming from an object : (Apple a) -> { System.out.println(a.getWeight()); } Select/extract from an object : (String s) -> s.length() Combine two values : (int a, int b) -> a * b Compare two objects : (Apple a1, Apple a2) -> a1.getWeight().compareTo(a2.getWeight()) List<Apple> greenApples = ...
Yorumlar
Yorum Gönder