要点
2014-03-18发布
lambda、stream、新日期、新注解
jdk-8u202:最后一个免费商用版本,Oracle于 2019-01-15 停止免费商用更新These Java SE 8 update releases are provided under the Java SE OTN License.
Java SE 8u202 and older updates are available, under the Binary Code License (“BCL”).
语言
lambda
有别于面向对象的方式,lambda是面向函数的
FunctionalInterface:第一次可以把函数作为参数,这个就很强大了
默认方法:在接口中直接提供方法的默认实现,如java.lang.Iterable {
default void forEach(Consumer super T> action) {
Objects.requireNonNull(action);
for (T t : this) {
action.accept(t);
}
}
}
类库
Stream API:数据源 → Stream → 中间操作 → 终端操作,还有并行流支持List ret = Arrays.asList("key#1", "demo1").stream().filter(v -> v.startsWith("key#")).collect(Collectors.toList());
Date
JDK7&