05 2020 档案

摘要:将ArrayList中的元素按照给定字符拼接起来 public static void main(String[] args) { List<String> list = Arrays.asList("nice","to","meet","you"); System.out.println(list 阅读全文
posted @ 2020-05-06 23:58 行云至他方 阅读(426) 评论(0) 推荐(0)
摘要:Collectors.toList()用来结束Stream流。 public static void main(String[] args) { List<String> list = Arrays.asList("hello","world","stream"); list.stream().ma 阅读全文
posted @ 2020-05-06 21:28 行云至他方 阅读(24764) 评论(0) 推荐(2)
摘要:Stream流的创建方法 public static void main(String[] args) { Stream stream1 = Stream.of("hello","world","hello stream"); String[] myArray = new String[]{"hel 阅读全文
posted @ 2020-05-06 18:56 行云至他方 阅读(289) 评论(0) 推荐(0)
摘要:方法引用实际上是Lambda表达式的一种语法糖 方法引用分为4类: 1.类名::静态方法名 public class Student { private String name; private int mark; public Student(String name, int mark) { th 阅读全文
posted @ 2020-05-06 16:04 行云至他方 阅读(196) 评论(0) 推荐(0)
摘要:Optional 可选,可能为null可能不为null,Java中解决空指针异常NullPointerException 一般情况下我们会 if(person != null){ ...... } Optional是基于值的一个final类,本身是一个容器,包着一个值。 public static 阅读全文
posted @ 2020-05-05 19:53 行云至他方 阅读(218) 评论(0) 推荐(0)
摘要:/** * Evaluates this predicate on the given argument. * * @param t the input argument * @return {@code true} if the input argument matches the predica 阅读全文
posted @ 2020-05-05 17:50 行云至他方 阅读(332) 评论(0) 推荐(0)
摘要:public class Person { private int age; private String name; public Person(String name,int age) { this.age = age; this.name = name; } public int getAge 阅读全文
posted @ 2020-05-05 16:35 行云至他方 阅读(1319) 评论(0) 推荐(0)
摘要:今天学习到了BiFunction这个函数接口,就地取材想到了我们公司发工资的这个应用场景。 @FunctionalInterface public interface BiFunction<T, U, R> T入参 U入参 R返回值 /** * Applies this function to th 阅读全文
posted @ 2020-05-05 15:52 行云至他方 阅读(609) 评论(0) 推荐(0)
摘要:简单的一个实例: public class JavaTest { public static void main(String[] args) { JavaTest javaTest = new JavaTest(); System.out.println("计算结果:"+ javaTest.com 阅读全文
posted @ 2020-05-05 15:07 行云至他方 阅读(146) 评论(0) 推荐(0)
摘要:在Java中,我们⽆无法将函数作为参数传递给⼀一个 ⽅方法,也⽆无法声明返回⼀一个函数的⽅方法。 Lambda表达式为Java添加了了缺失的函数式编程特 性,使我们能将函数当做⼀一等公⺠民看待 在将函数作为⼀一等公⺠民的语⾔言中,Lambda表达式 的类型是函数。但在Java中,Lambda表达式是 阅读全文
posted @ 2020-05-05 08:36 行云至他方 阅读(183) 评论(0) 推荐(0)