zoukankan      html  css  js  c++  java
  • 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}})

     

  • 相关阅读:
    面向对象的程序设计-继承
    Chrome开发工具之Console
    面向对象的程序设计-原型模式
    面向对象的程序设计-工厂模式、构造函数模式
    面向对象的程序设计-理解对象
    引用类型-Array类型
    引用类型-Object类型
    单体内置对象
    基本包装类型
    引用类型-Function类型
  • 原文地址:https://www.cnblogs.com/immiao0319/p/15154947.html
Copyright © 2011-2022 走看看