|
@@ -0,0 +1,39 @@
|
|
|
+package com.sf.day08.lambda;
|
|
|
+
|
|
|
+import org.junit.Test;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+public class Te {
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ List<Product> productByPrice = findProductByPrice(Data.products);
|
|
|
+ System.out.println(productByPrice);
|
|
|
+ List<Product> productByName = findProductByName(Data.products);
|
|
|
+ System.out.println(productByName);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public static List<Product> findProductByPrice(List<Product> products){
|
|
|
+ List<Product> lists = new ArrayList<>();
|
|
|
+ for (Product product : products) {
|
|
|
+ if(product.getPrice() > 1000){
|
|
|
+ lists.add(product);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return lists;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static List<Product> findProductByName(List<Product> products){
|
|
|
+ List<Product> lists = new ArrayList<>();
|
|
|
+ for (Product product : products) {
|
|
|
+ if(product.getName().contains("手机")){
|
|
|
+ lists.add(product);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return lists;
|
|
|
+ }
|
|
|
+}
|