《core JAVA for the impatient》阅读笔记(2) lambda表达式

lambda表达式

  • 只有一个抽象方法的接口对象,就可以提供一个lambda表达式(函数式接口)
  • 将lambda表达式放入类型为函数式接口的变量中,这样它就被转换为该接口的实例
  • list.removeIf(e ->e==null)
  • Arrays.sort(words,(first,second)->first.length()-second.length())
  • 不区分大小写的方法引用:
  • Arrays.sort(words,(first,second)->first.compareToignoreCase(second))
  • 三种使用方式
  1. 类::实例方法
    String::compareToIgnoreCase等同于(x,y) -> x.compareToIgnoreCase(y)
  2. 类::静态方法
    Objects::isNull等同于x->Objects.isNull(x)
  3. 对象::实例方法
    System.out::println等同于x ->System.out.println(x)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
The release of Java SE 8 introduced significant enhancements that impact the Core Java technologies and APIs at the heart of the Java platform. Many old Java idioms are no longer required and new features like lambda expressions will increase programmer productivity, but navigating these changes can be challenging., , Core Java® for the Impatient is a complete but concise guide to Java SE 8. Written by Cay Horstmann—the author of Java SE 8 for the Really Impatient and Core Java™, the classic, two-volume introduction to the Java language—this indispensable new tutorial offers a faster, easier pathway for learning the language and libraries. Given the size of the language and the scope of the new features introduced in Java SE 8, there’s plenty of material to cover, but it’s presented in small chunks organized for quick access and easy understanding., , If you’re an experienced programmer, Horstmann’s practical insights and sample code will help you quickly take advantage of lambda expressions (closures), streams, and other Java language and platform improvements. Horstmann covers everything developers need to know about modern Java, including, - Crisp and effective coverage of lambda expressions, enabling you to express actions with a concise syntax, - A thorough introduction to the new streams API, which makes working with data far more flexible and efficient, - A treatment of concurrent programming that encourages you to design your programs in terms of cooperating tasks instead of low-level threads and locks, - Up-to-date coverage of new libraries like Date and Time, - Other new features that will be especially valuable for server-side or mobile programmers, Whether you are just getting started with modern Java or are an experienced developer, this guide will be invaluable for anyone who wants to write tomorrow’s most robust, efficient, and secure Java code.
经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值