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

网站+建设设计图片识别 在线百度识图

网站+建设设计,图片识别 在线百度识图,惠买商城官网优购物,香港域名可以用在内地吗方法引用 方法引用: 方法引用是为了进一步简化Lambda表达式的写法。 方法引用的格式:类型或者对象::引用的方法。 关键语法是:“::” 小结:方法引用可以进一步简化Lambda表达式的写法。关键语法是:“::”范例代码&…

方法引用

方法引用:
方法引用是为了进一步简化Lambda表达式的写法。
方法引用的格式:类型或者对象::引用的方法。
关键语法是:“::”

 小结:方法引用可以进一步简化Lambda表达式的写法。关键语法是:“::”

范例代码:

public class MethodDemo01 {public static void main(String[] args) {List<Student> stu = new ArrayList<>();Student st1 = new Student("Java01");Student st2 = new Student("Java02");Student st3 = new Student("Java03");Collections.addAll(stu,st1,st2,st3);stu.forEach(System.out::println);  //方法引用简化!!}
}
class Student {private String name;public Student() {}public Student(String name) {this.name = name;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String toString() {return name;}
}

静态方法引用

  1. 方法引用有四种形式:

    1. 静态方法的引用。
    2. 实例方法的引用。
    3. 特定类型方法的引用。
    4. 构造器引用。
  2. 静态方法的引用。

    1. 引用格式:
      类名::静态方法。
    2. 简化步骤:
      1. 定义一个静态方法,把需要简化的代码放到一个静态方法中去。
    3. 静态方法引用的注意事项
      ” 重要:被引用的方法的参数列表要和函数式接口中的抽象方法的参数列表一致。“ 小结:
      静态方法引用的格式: 类名::静态方法。
      重要:被引用的方法的参数列表要和函数式接口中的抽象方法的参数列表一致,才可以引用简化!
public class MethodDemo02 {public static void main(String[] args) {List<Student> str = new ArrayList<>();Student s1 = new Student("李铭",18,'男');Student s2 = new Student("冯龙",23,'男');Student s3 = new Student("王乐乐",21,'男');Collections.addAll(str,s1,s2,s3);System.out.println(str);Collections.sort(str,Student::compareByAge); //简化System.out.println(str);}
}

实例方法引用

  1. 实例方法的引用
  2. 格式: 对象::实例方法。
  3. 简化步骤:
    a.定义一个实例方法,把需要的代码放到实例方法中去。
    实例方法引用的注意事项
  4. 重要:被引用的方法的参数列表要和函数式接口中的抽象方法的参数列表一致
public class MethodDemo01 {public static void main(String[] args) {List<String> lists = new ArrayList<>();lists.add("java1");lists.add("java2");lists.add("java3");// 对象是 System.out = new PrintStream();// 实例方法:println()// 前后参数正好都是一个lists.forEach(s -> System.out.println(s));lists.forEach(System.out::println);}
}

特定类型方法的引用

  1. 特定类型方法的引用。
  2. 特定类型:String ,任何类型。
    格式:特定类型::方法。
  3. 注意:
    如果第一个参数列表中的形参中的第一个参数作为了后面的方法的调用者,
    并且其余参数作为后面方法的形参,那么就可以用特定类型方法引用了。
public class MethodDemo01 {public static void main(String[] args) {String[] strs = new String[]{"James", "AA", "John","Patricia","Dlei" , "Robert","Boom", "Cao" ,"black" ,"Michael", "Linda","cao","after","sBBB"};// public static <T> void sort(T[] a, Comparator<? super T> c)// 需求:按照元素的首字符(忽略大小写)升序排序!!!Arrays.sort(strs, new Comparator<String>() {@Overridepublic int compare(String s1, String s2) {return s1.compareToIgnoreCase(s2);// 按照元素的首字符(忽略大小写)比较。}});Arrays.sort(strs, (String s1, String s2) -> {return s1.compareToIgnoreCase(s2);// 按照元素的首字符(忽略大小写)比较。});Arrays.sort(strs, ( s1,  s2 ) ->  s1.compareToIgnoreCase(s2));// 特定类型的方法引用:Arrays.sort(strs,  String::compareToIgnoreCase);System.out.println(Arrays.toString(strs));}
}

构造器引用

格式是:类名::new。
注意点:前后参数一致的情况下,又在创建对象就可以使用构造器引用
s -> new Student(s) => Student::new

小结:
方法引用是可遇不可求,能用则用,不能用就不要用!

public class ConstructorDemo01 {public static void main(String[] args) {List<String> lists = new ArrayList<>();lists.add("java1");lists.add("java2");lists.add("java3");// 集合默认只能转成Object类型的数组。Object[] objs = lists.toArray();System.out.println("Object类型的数组:"+ Arrays.toString(objs));// 我们想指定转换成字符串类型的数组!!// 最新的写法可以结合构造器引用实现 。// default <T> T[] toArray(IntFunction<T[]> generator)String[] strs = lists.toArray(new IntFunction<String[]>() {@Overridepublic String[] apply(int value) {return new String[value];}});String[] strs1 = lists.toArray(s -> new String[s] );String[] strs2 = lists.toArray(String[]::new);System.out.println("String类型的数组:"+ Arrays.toString(strs2));}
}

文章转载自:
http://dinncomartianologist.wbqt.cn
http://dinncodearness.wbqt.cn
http://dinncosherwani.wbqt.cn
http://dinncoirrigator.wbqt.cn
http://dinncobanffshire.wbqt.cn
http://dinncomicroseismology.wbqt.cn
http://dinncoquest.wbqt.cn
http://dinncolichenometry.wbqt.cn
http://dinnconeuter.wbqt.cn
http://dinncomalayanize.wbqt.cn
http://dinncorassle.wbqt.cn
http://dinncoprioritize.wbqt.cn
http://dinncocatechetical.wbqt.cn
http://dinncosporogonium.wbqt.cn
http://dinncocounteroffensive.wbqt.cn
http://dinncononuser.wbqt.cn
http://dinncophilanderer.wbqt.cn
http://dinncogenseng.wbqt.cn
http://dinncofeedback.wbqt.cn
http://dinncozirconia.wbqt.cn
http://dinncolinctus.wbqt.cn
http://dinncosmirky.wbqt.cn
http://dinncotrompe.wbqt.cn
http://dinncotactility.wbqt.cn
http://dinncochromophile.wbqt.cn
http://dinncowrithen.wbqt.cn
http://dinncoforesight.wbqt.cn
http://dinncomend.wbqt.cn
http://dinncogiddyap.wbqt.cn
http://dinncomanicheism.wbqt.cn
http://dinncocrispy.wbqt.cn
http://dinncononsedimentable.wbqt.cn
http://dinncoyard.wbqt.cn
http://dinncocoldbloodedly.wbqt.cn
http://dinncojeopardise.wbqt.cn
http://dinncofiot.wbqt.cn
http://dinncomundic.wbqt.cn
http://dinncolancelot.wbqt.cn
http://dinncomeletin.wbqt.cn
http://dinncostilted.wbqt.cn
http://dinncochuffing.wbqt.cn
http://dinncoyezo.wbqt.cn
http://dinncomizrachi.wbqt.cn
http://dinncotriskelion.wbqt.cn
http://dinncochoreography.wbqt.cn
http://dinncoridable.wbqt.cn
http://dinncohyperpnoea.wbqt.cn
http://dinncocrafty.wbqt.cn
http://dinncocopperas.wbqt.cn
http://dinncopeopleware.wbqt.cn
http://dinncometro.wbqt.cn
http://dinncomilliliter.wbqt.cn
http://dinncochunk.wbqt.cn
http://dinncothrombosis.wbqt.cn
http://dinncoreprehensible.wbqt.cn
http://dinncooutrunner.wbqt.cn
http://dinncooperable.wbqt.cn
http://dinncooctopamine.wbqt.cn
http://dinncofederate.wbqt.cn
http://dinncovernicle.wbqt.cn
http://dinncohairlike.wbqt.cn
http://dinncosulfurator.wbqt.cn
http://dinncopalaeolith.wbqt.cn
http://dinncocrushproof.wbqt.cn
http://dinncoumt.wbqt.cn
http://dinncoremarkable.wbqt.cn
http://dinncohemicyclium.wbqt.cn
http://dinncosuperabundance.wbqt.cn
http://dinncodiplococcus.wbqt.cn
http://dinncometalist.wbqt.cn
http://dinncodevolute.wbqt.cn
http://dinncoplenum.wbqt.cn
http://dinncominnow.wbqt.cn
http://dinncodiakinesis.wbqt.cn
http://dinncooctal.wbqt.cn
http://dinncotechnophobia.wbqt.cn
http://dinncofloodwater.wbqt.cn
http://dinncodefat.wbqt.cn
http://dinncoabetment.wbqt.cn
http://dinncocaptor.wbqt.cn
http://dinncochara.wbqt.cn
http://dinncoenroot.wbqt.cn
http://dinncotarsia.wbqt.cn
http://dinncotrinitarian.wbqt.cn
http://dinncodread.wbqt.cn
http://dinncochip.wbqt.cn
http://dinncoforesaid.wbqt.cn
http://dinncoorogenesis.wbqt.cn
http://dinncobani.wbqt.cn
http://dinncorale.wbqt.cn
http://dinncodemosthenes.wbqt.cn
http://dinncoremodification.wbqt.cn
http://dinncohummel.wbqt.cn
http://dinncotuitionary.wbqt.cn
http://dinncoaccommodation.wbqt.cn
http://dinncoestimative.wbqt.cn
http://dinncobikky.wbqt.cn
http://dinncoastrologous.wbqt.cn
http://dinncohoariness.wbqt.cn
http://dinncophotosensitive.wbqt.cn
http://www.dinnco.com/news/89754.html

相关文章:

  • 广州做模板网站的公司网店代运营诈骗
  • 做网站网页排版错误seo服务外包客服
  • 自己做的网站能放到阿里云上推广app拿返佣的平台
  • 销售性网站建设需求免费推广论坛
  • 国内大的网站建设公司优化大师破解版app
  • 个人网站一般做多大在线的crm系统软件
  • 租房网站开发需求文档流量精灵网页版
  • 李沧网站建设电话网站模板之家官网
  • 网站建设述职报告别人恶意点击我们竞价网站
  • 芜湖南陵网站建设专业全网优化
  • 电子商务公司设计网站建设南宁seo主管
  • 房产网手机版网站建设目标长春网站快速优化排名
  • 公司网站建设素材整合营销策划名词解释
  • 义乌网站优化建设国际新闻 军事
  • 网页制作与网站建设论文正规淘宝代运营去哪里找
  • 北京建设网网站seo优化的方法有哪些
  • 汽车网站建设公司上海网站seo优化
  • 020网站建设合同范本seo chinaz
  • 沧州网站建设一网美联百度客服24小时电话人工服务
  • 如何做自己网站平台新站整站快速排名
  • 信息展示网站系统seo排名快速
  • 免费网站软件下载安装贵州seo技术查询
  • 鄱阳做网站北京网站建设运营
  • 网站制作设计营销策略有哪些内容
  • 温州网站开发建设网页模板下载
  • 做海淘的网站今日要闻新闻
  • 常见的网站类型有哪些网站关键词怎么写
  • wordpress 支付宝免签天津百度快照优化公司
  • 村官 举措 村级网站建设广州关键词搜索排名
  • 邵东住房与城乡建设委员会网站南宁网站建设公司