Search Results for: String instruments
举例: () -> //参数为空,返回一个int (list list) -> list.isempty() //参数为list,返回一个boolean (int x, int y) -> x*y //参数为两个int,返回一个int (string s) -> system.out.println(s); //参数为一个string,不返回结果 (string s) -> {system.out.println(s);} //参数为一个string,打印字符串 哪些地方使用哪些lambda 函数式接口是只定义一个抽象方法的接口,即使拥有多个默认方法。
例子: public void execute(runnable r){ r.run(); } execute(() -> {}); //使用lambda,runnable是参数为空,没有返回值的函数式接口,即() -> void //fetch返回一个函数式接口,() -> string public callable fetch() { return () -> "tricky example ;-)"; } 为什么只有在函数式接口的地方使用呢?...
http://www.iis7.com/a/nr/0712833.html