done apple_Infosys_Jugal 要求完整写出Java8 stream
public static int sum(final List<String> l) { return int sum = Stream().map(n -> Integer.valueOf(n)).sum(); } {"2","3","5"} => 10 private static final List<String> SKIP_WORDS = Arrays.asList("AND", "OR", "BY", "OF"); public static String acronym(final String input) { return String string = Stream() .filter(input.split(" ").toArray() -> (!input.split(" ").toArray().contains("AND")) && ("OR")... ) .map(input.split(" ").toArray() -> input.split(" ").toArray().charAt(0)); } INPUT OUTPUT United States of America USA National Aeronautics and Space Administration NASA light AMplification by stimuLAtion of Emitted Radiation LASER public static List<int> findIndex(List<int> num, int target){ return List<int> list = new Stream("0,1,2,3").map(x,y -> (num.get(x) + num.get(y) == target)); } [2,7,6,1],7 => [2,3] /user/welcome?fname=abc&lname=xyz @RestController @RequestMapping("/user/welcome") public class RestController() { @GettingMapping("/fname", produces"application/json") public String fname(String fname) { return fname; } //same for lname } { "address": { "building": "1007", "coord": [ -73.856077, 40.848447 ], "street": "Morris Park Ave", "zipcode": "10462" }, "borough": "Bronx", "cuisine": "Bakery", "grades": [ { "date": { "$date": 1393804800000 }, "grade": "A", "score": 2 }, { "date": { "$date": 1378857600000 }, "grade": "A", "score": 6 }, { "date": { "$date": 1358985600000 }, "grade": "A", "score": 10 }, { "date": { "$date": 1322006400000 }, "grade": "A", "score": 9 }, { "date": { "$date": 1299715200000 }, "grade": "B", "score": 14 } ], "name": "Morris Park Bake Shop", "restaurant_id": "30075445" } db.inventory.find({address:{zipcode: 10462}})