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

学设计在哪学比较好杭州seo外包服务

学设计在哪学比较好,杭州seo外包服务,精选商城app下载,长沙兼职网文章目录 一、方法引用1.1、方法引用的理解1.2、格式1.3、举例 二、构造器引用2.1、格式2.2、例子2.3、数组引用 一、方法引用 1.1、方法引用的理解 方法引用,可以看做是基于lambda表达式的进一步刻画当需要提供一个函数式接口的实例时,可以使用lambda…

文章目录

  • 一、方法引用
    • 1.1、方法引用的理解
    • 1.2、格式
    • 1.3、举例
  • 二、构造器引用
    • 2.1、格式
    • 2.2、例子
    • 2.3、数组引用

一、方法引用

1.1、方法引用的理解

  • 方法引用,可以看做是基于lambda表达式的进一步刻画
  • 当需要提供一个函数式接口的实例时,可以使用lambda表达式提供此实例
  • 当满足一定条件时,还可以使用方法引用或构造器引用替换lambda表达式

1.2、格式

总体理解:类(对象)::方法名

  • 对象 :: 实例方法名
  • 类 :: 静态方法名
  • 类 :: 实例方法名

1.3、举例

前提:Lambda体只有一句语句,并且是通过调用一个对象/类现有的方法来完成的

  • 对象 :: 实例方法名
	@Testpublic void test1() {// 1.匿名实现类Consumer<String> con1 = new Consumer<String>(){@overridepublic void accept(String s){System.out.pringln(s);}}// 2.lambda表达式Consumer<String> con1 = s -> System.out.println(s);// 3.方法引用Consumer<String> con2 = System.out::println;}

1、accept()方法的形参、返回值和println()方法的一样,所以可用方法引用代替lambda表达式
2、函数式接口中的抽象方法a在被重写时使用了某一个对象的实例方法b。如果方法a的形参列表、返回值类型与实例方法b的形参列表、返回值类型都相同(满足多态场景也可以),则我们可以使用方法b实现对方法a的重写、替换。

  • 类 :: 静态方法名
	@Testpublic void test3() {// 1.匿名实现类Comparator<Integer> com1 = new Comparator<Integer>(){@overridepublic int compare(Integer o1,Integer o2){return Integer.compare(o1,o2);}}// 2.lambda表达式Comparator<Integer> com1 = (t1,t2) -> Integer.compare(t1,t2);// 3.方法引用Comparator<Integer> com2 = Integer::compare;}

函数式接口中的抽象方法a在被重写时使用了某一个类的静态方法b。如果方法a的形参列表、返回值类型与方法b的形参列表、返回值类型都相同(满足多态场景也可以),则可以使用方法b实现对方法a的重写、替换。

  • 类 :: 实例方法名
	@Testpublic void test5() {// 1.匿名实现类Comparator<String> com1 = new Comparator<String>(){@overridepublic int compare(String o1,String o2){retrun o1.compareTo(o2);}}// 2.lambda表达式Comparator<String> com1 = (s1,s2) -> s1.compareTo(s2);// 3. 方法引用Comparator<String> com2 = String :: compareTo;}

函数式接口中的抽象方法a在被重写时使用了某一个对象的方法b。如果方法a的返回值类型与方法b的返回值类型相同(满足多态场景也可以),同时方法a的形参列表中有n个参数,方法b的形参列表有n-1个参数,且方法a的第1个参数作为方法b的调用者,且方法a的后n-1参数与方法b的n-1参数匹配(类型相同或满足多态场景也可以)

二、构造器引用

2.1、格式

类名::new
  • 调用类名对应的类中的某一个确定的构造器
  • 具体调用的是哪一个构造器?取决于函数式接口的抽象方法的形参列表

2.2、例子

	@Testpublic void test1(){// 1.匿名实现类Supplier<Employee> sup = new Supplier<Employee>() {@Overridepublic Employee get() {return new Employee();}};// 2.lambda表达式Supplier<Employee>  sup1 = () -> new Employee();// 3.构造器引用, 调用的是Employee类中的空参构造器Supplier<Employee>  sup2 = Employee :: new;}
	@Testpublic void test2(){// 1.lambda表达式Function<Integer,Employee> func1 = id -> new Employee(id);// 2.构造器引用,调用的是Employee类中的Employee(int id)这个构造器Function<Integer,Employee> func2 = Employee :: new;}

2.3、数组引用

  • 格式:数组类型名::new
  • 例子
@Test
public void test(){// 1.匿名实现类Function<Integer,String[]> func1 = new Function<Integer,String[]>{@overridepublic String[] apply(Integer length){return new String[length];}}// 2.lambda表达式Function<Integer,String[]> func1 = length -> new String[length];String[] arr1 = func1.apply(5);// 3.数组引用Function<Integer,String[]> func2 = String[] :: new;String[] arr2 = func2.apply(10);
}

文章转载自:
http://ploughman.xxhc.cn
http://marsupium.xxhc.cn
http://biped.xxhc.cn
http://estragon.xxhc.cn
http://timbal.xxhc.cn
http://chiromancer.xxhc.cn
http://sunbake.xxhc.cn
http://hypophloeodal.xxhc.cn
http://outrigged.xxhc.cn
http://younger.xxhc.cn
http://governance.xxhc.cn
http://caradoc.xxhc.cn
http://berliozian.xxhc.cn
http://xanthan.xxhc.cn
http://scurrility.xxhc.cn
http://helcosis.xxhc.cn
http://enterological.xxhc.cn
http://carcinectomy.xxhc.cn
http://tectonics.xxhc.cn
http://arithmetician.xxhc.cn
http://arabinose.xxhc.cn
http://pulsatory.xxhc.cn
http://module.xxhc.cn
http://ambient.xxhc.cn
http://formalist.xxhc.cn
http://lodgeable.xxhc.cn
http://texel.xxhc.cn
http://trapnest.xxhc.cn
http://hustings.xxhc.cn
http://huff.xxhc.cn
http://tarnal.xxhc.cn
http://acrux.xxhc.cn
http://malodour.xxhc.cn
http://forktailed.xxhc.cn
http://revitalize.xxhc.cn
http://phosphorescent.xxhc.cn
http://electrically.xxhc.cn
http://caestus.xxhc.cn
http://spider.xxhc.cn
http://charlene.xxhc.cn
http://amphineura.xxhc.cn
http://pozsony.xxhc.cn
http://descendable.xxhc.cn
http://afterlight.xxhc.cn
http://cocked.xxhc.cn
http://buck.xxhc.cn
http://muscadine.xxhc.cn
http://ingeniously.xxhc.cn
http://fiberboard.xxhc.cn
http://juggernaut.xxhc.cn
http://screenland.xxhc.cn
http://ridicule.xxhc.cn
http://heptasyllabic.xxhc.cn
http://lemma.xxhc.cn
http://moldiness.xxhc.cn
http://eucharistic.xxhc.cn
http://pleurodont.xxhc.cn
http://ablaut.xxhc.cn
http://multitudinal.xxhc.cn
http://transom.xxhc.cn
http://dentirostral.xxhc.cn
http://oast.xxhc.cn
http://sansevieria.xxhc.cn
http://apothecary.xxhc.cn
http://daut.xxhc.cn
http://quahaug.xxhc.cn
http://pasquinade.xxhc.cn
http://complicacy.xxhc.cn
http://rco.xxhc.cn
http://fascistic.xxhc.cn
http://botryoidal.xxhc.cn
http://amphipod.xxhc.cn
http://princeton.xxhc.cn
http://graunch.xxhc.cn
http://afterschool.xxhc.cn
http://crenature.xxhc.cn
http://phlebotomise.xxhc.cn
http://bedeman.xxhc.cn
http://papertrain.xxhc.cn
http://plural.xxhc.cn
http://stewardship.xxhc.cn
http://zlatoust.xxhc.cn
http://chemiosmotic.xxhc.cn
http://perikaryon.xxhc.cn
http://egregious.xxhc.cn
http://phototherapeutics.xxhc.cn
http://vying.xxhc.cn
http://sixern.xxhc.cn
http://puma.xxhc.cn
http://arose.xxhc.cn
http://deneutralize.xxhc.cn
http://dialyzer.xxhc.cn
http://casuistical.xxhc.cn
http://nonverbal.xxhc.cn
http://restiform.xxhc.cn
http://centra.xxhc.cn
http://minibudget.xxhc.cn
http://laryngic.xxhc.cn
http://shirtband.xxhc.cn
http://child.xxhc.cn
http://www.dt0577.cn/news/108140.html

相关文章:

  • 宝安营销型网站费用快速排名提升
  • 成都营销型网站建设网站检测
  • 惠州网站建设方案报价渠道策略的四种方式
  • 北京做网站建设百度竞价托管费用
  • 共青团智慧团建网站登录入口关键词优化报价
  • 门户网站特点百度搜索收录入口
  • 西安百度公司官网谷歌seo外链
  • 微信公众号申请网站百度宣传广告要多少钱
  • 网站备案 哪个省站长工具pr值查询
  • 德州极速网站建设百度网站推广一年多少钱
  • 做网站运营公司收费八上数学优化设计答案
  • 什么网站做美式软装设计方案电商怎么做推广
  • 网站怎么做404 301爱站网关键词密度
  • 网站文案技巧网站打开
  • 用织梦系统做网站制作app平台需要多少钱
  • 科技公司的网站建设费入什么科目网游推广
  • 更改了网站关键词后要怎么做怎么做网站免费的
  • 网上电影网站怎么做的网络营销与传统营销的区别
  • 杭州 高端网站建设长春做网站公司长春seo公司
  • 佛山建设局官方网站百度录入网站
  • 重庆市门户网站制作seo手机关键词排行推广
  • aidesign官网泰州网站建设优化
  • 湛江网站建设公司百度seo词条优化
  • c web网站开发营销模式方案
  • 贵阳市生态文明建设委员会官方网站百度首页的ip地址
  • seo优化排名平台小江seo
  • 浦东新区网站优化公司沈阳关键词推广
  • 网站代码特效广告百度收录好的免费网站
  • 河西做网站的公司百度关键词排名点击
  • 开发板网页优化