JDK新特性

JDK 8:

  • Lambda表达式
  • Stream流
  • 日期类
  • 接口的默认方法、静态方法
  • Optional
  • CompletableFuture

JDK 17:

  • instanceof的匹配增强,不需要进行强转了,例如 if (obj instanceof String s) {System.out.println(s.toUpperCase())};
  • Text Blocks文本块:

  • switch表达式