Java-Java8

1.Java语言与IDE

1995-JDK1.0;2003-JDK1.5;2011-JDK7;2014-JDK8;2017-JDK9

JVM-java虚拟机,.class字节码文件,“一次编译,到处运行”

Java8新特性:

lambda表达式:定义:f = lambda x,y:x+y 使用:f(2,3)=5

接口:新增方法,方法修饰符default和static,这两个方法不是抽象的,有具体的代码实现

日期的API:包java.time 

    类:LocalDate,LocalTime,LocalDateTime;DateFommatter,FormmatStyle(枚举)

    方法:LocalDate,LocalTime,LocalDateTime{静态方法:of(year,month,day),parse(str,DateFormamter.ofPattern(str)(输入解析)),now(),普通方法:format(DateTimeFormatter.ofLocalizedDate(FormmatStyle.FULL))(输出格式化),其他的get set年月日周方法,minusXxx()/plusXxx()方法是在某个时间下减去/加上某段时间,某个时间离当前时间有几周、几日...}

流:

获取流:Stream.of(),Arrays.stream(),集合实例.stream()

Java7简化了IO操作,Files,Paths

Java8 Lambda接口:

xxxFunction:数据转换处理,返回一个值;xxxConsumer:数据转化处理,无返回值;

xxxPredicate:过滤,返回boolean;

lambda表达式:n->n*2   m->{if(m%2==0) return m;} String::toUpperCase

filter(),map(),reduce(),collect(),forEach(),iterator(),distinct()去重,max(),min(),sort()

filter()参数为xxxPredicate类型,参数返回boolean

map()参数为xxxFunction类型,方法参数Boolean返回Boolean集合的流...

max()参数为java.util.Comparator类型

类:java.util.stream.Collectors,collect()参数为Collectors类型

Map<Object, List<String>> collect = streamStr.collect(Collectors.groupingBy(str->str.contains("A")));//方法参数 Boolean,分组以Boolean分组;str->{if(str.contains("A")) return str}
collect.forEach((m,n)->{
System.out.println(m);
n.forEach(System.out::println);
});



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值