当前位置: 首页 > news >正文

青岛的公司网站标题seo外包优化

青岛的公司,网站标题seo外包优化,电子商务网站建设课设学生体会,如何让企业网站四大函数式接口 函数式接口:只有一个方法的接口 ,例如:Runnable接口 Function 函数型接口,有一个输入参数,有一个输出 源码: /*** Represents a function that accepts one argument and produces a resul…

四大函数式接口

函数式接口:只有一个方法的接口 ,例如:Runnable接口

Function

函数型接口,有一个输入参数,有一个输出

源码:

/*** Represents a function that accepts one argument and produces a result.** This is a functional interface* whose functional method is apply(Object).** @param <T> the type of the input to the function* @param <R> the type of the result of the function** @since 1.8*/
@FunctionalInterface
public interface Function<T, R> {/*** Applies this function to the given argument.** @param t the function argument* @return the function result*/R apply(T t);

示例:

package function;import java.util.function.Function;/**** Function 函数型接口,有一个输入参数,有一个输出* 只要是函数式接口,就可以用lambda表达式*/
public class Demo01 {public static void main(String[] args) {// 匿名内部类,工具类,输出输入的结果
//        Function function = new Function<String,String>() {
//            @Override
//            public String apply(String s) {
//
//                return null;
//            }
//        };// 使用lambda表达式Function function = (str)->{return str;};System.out.println(function.apply("abc"));}
}

Predicate

断定型接口:只有一个输入参数,返回值为boolean

源码:

/*** Represents a predicate (boolean-valued function) of one argument.** This is a functional interface* whose functional method is test(Object).** @param <T> the type of the input to the predicate** @since 1.8*/
@FunctionalInterface
public interface Predicate<T> {/*** Evaluates this predicate on the given argument.** @param t the input argument* @return {@code true} if the input argument matches the predicate,* otherwise {@code false}*/boolean test(T t);

示例

package function;import java.util.function.Predicate;/**** 断定型接口:有一个输入参数,返回值为boolean*/
public class Demo02 {public static void main(String[] args) {// 判断字符串是否为空
//        Predicate predicate = new Predicate<String>() {
//            @Override
//            public boolean test(String s) {
//                return s.isEmpty();
//            }
//        };// 函数型接口+lambda表达式,使代码看起来更加简洁Predicate<String> predicate = (s)->{return s.isEmpty();};System.out.println(predicate.test(""));}
}

Consumer

消费型接口,有一个参数,没有返回值

源码:

/*** Represents an operation that accepts a single input argument and returns no* result. Unlike most other functional interfaces, {@code Consumer} is expected* to operate via side-effects.** <p>This is afunctional interface* whose functional method is accept(Object).** @param <T> the type of the input to the operation** @since 1.8*/
@FunctionalInterface
public interface Consumer<T> {/*** Performs this operation on the given argument.** @param t the input argument*/void accept(T t);

示例

package function;import javax.lang.model.element.NestingKind;
import java.util.function.Consumer;/**** Consumer 消费型接口:只有输入,没有返回值*/
public class Demo03 {public static void main(String[] args) {
//        Consumer<String> consumer = new Consumer<String>() {
//            @Override
//            public void accept(String s) {
//                System.out.println(s);
//            }
//        };Consumer<String> consumer = (s)->{System.out.println(s);};consumer.accept("asd");}
}

Supplier

供给型接口:没有参数,只有返回值

源码:

/*** Represents a supplier of results.** There is no requirement that a new or distinct result be returned each* time the supplier is invoked.** <This is a functional interface* whose functional method isget().** @param <T> the type of results supplied by this supplier** @since 1.8*/
@FunctionalInterface
public interface Supplier<T> {/*** Gets a result.** @return a result*/T get();
}

示例

package function;import java.util.function.Supplier;/**** 供给型接口:没有参数,只有返回值*/
public class Demo04 {public static void main(String[] args) {
//        Supplier<Integer> supplier = new Supplier<Integer>() {
//
//            @Override
//            public Integer get() {
//                return 1024;
//            }
//        };Supplier<Integer> supplier  = ()->{return 1024;};System.out.println(supplier.get());}
}

为什么要学习函数式接口?

  • 简化编程模型,使代码更加可读易懂

  • 在新版本的框架底层中,函数式接口有大量的应用

http://www.tj-hxxt.cn/news/26138.html

相关文章:

  • 怎么用腾讯云服务器做网站今日新闻十大头条内容
  • 上海的网站建设公司哪家好无锡百度推广开户
  • 个人网站优秀作品谷歌 chrome 浏览器
  • 个人做民宿需要建立网站吗常德今日头条新闻
  • 商城和营销型网站建设关键词推广优化外包
  • 石家庄房地产网站建设重庆seo团队
  • wordpress 帮助 主题关键词优化举例
  • 网站企业建设优化建议
  • 天津做网站软件百度上打广告怎么收费
  • 做交易平台网站外链link
  • 我要注册公司怎么办seo综合查询站长工具关键词
  • 低价网站制作企业网络推广员要怎么做
  • 大港油田建设官方网站网购网站十大排名
  • 东台做网站的企业网站seo平台
  • 做网站用什么软件知乎最新新闻事件今天疫情
  • 网站推广大概需要多少钱百度搜索技巧
  • 找网站做襄阳seo优化排名
  • 郑州网站建站免费seo网站优化工具
  • 做微信扫码网站seo网络优化公司哪家好
  • 网站首页效果图怎么做上海牛巨微seo
  • 网站的滚屏切换是怎么做的谷歌关键词排名查询工具
  • 建设茶叶网站目的点击排名软件哪个好
  • 一些简单的代码网络搜索引擎优化
  • 2021ppt模板免费下载 素材一键关键词优化
  • 织梦可以做B2B信息发布网站吗windows7优化大师
  • 做的最好的微电影网站有哪些长春刚刚最新消息今天
  • 企业做网站上海seo搜索引擎优化工程师招聘
  • 百度网盘app下载安装兰州网站优化
  • 南昌建站黑锋网seo
  • 图片二维码制作网站新乡搜索引擎优化