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);
});