[TOC] <br/><br/><br/> # <b style="color:#4F4F4F;">简介说明</b> 结构脑图:[地址](http://naotu.baidu.com/file/efdb23d4a5745f3b559db095e0aa312e?token=89f5c97fb48a4ebd) 原文链接: - [JAVA](https://docs.oracle.com/javase/8/docs/api/) - [JAVA(CN)](https://www.matools.com/api/java8) ``` 版本:Java8 作用:面向对象编程语言,不仅吸收了C++语言的各种优点,还摒弃了C++里难以理解的多继承、指针等概念 ``` <br/> # <b style="color:#4F4F4F;">基本语法</b> <br/> # <span style="color:#619BE4">@interface</span> ***** 声明自定义注解 <br/> # <span style="color:#619BE4">native</span> ***** 本地,原生方法(非 Java 实现) <br/> # <span style="color:#619BE4">default</span> ***** 为接口添加方法体 <br/> # <span style="color:#619BE4">synchronized</span> ***** 线程,同步 <br/> # <span style="color:#619BE4">volatile</span> ***** 保证线程可见性,且提供了一定的有序性 <br/> # <span style="color:#619BE4">transient</span> ***** 变量被transient修饰,变量将不再是对象持久化的一部分,该变量内容在序列化后无法获得访问 <br/> # <span style="color:#619BE4">T</span> ***** 泛型 <br/> ### 示例内容 <span style="color:red;">1. 泛型约束</span> ``` # 无限通配符 ? # 定义泛型约束 ? extends WhatClass # 定义泛型通配符下限 ? super WhatClass ``` <br/> # <span style="color:#619BE4">::</span> ***** 双冒号,静态方法引用 <br/> # <span style="color:#619BE4">Type...</span> ***** 解构传入参数 <br/> # <span style="color:#619BE4">Lambda</span> ***** 匿名函数表达式 <br/> ### 示例内容 <span style="color:red;">1. 举例说明</span> ``` interface IWhat { void What(); } public class Trial { public static void main(String[] args) { hello(() -> System.out.println("hello")); } static void hello(IWhat what) { what.What(); } } ``` <span style="color:red;">2. 传递类类型</span> ``` class What { String name = "what is my name"; } interface IWhat { What What(); } public class Trial { public static void main(String[] args) { hello(What::new); } static void hello(IWhat what) { What w = what.What(); System.out.println(w.name); } } ``` <br/> # <span style="color:#619BE4">try-with-resources</span> ***** ARM 块(Automatic Resource Management) ,自动资源管理 <br/> ### 示例内容 <span style="color:red;">1. 举例说明</span> ``` class What implements AutoCloseable { String name = "what is my name"; @Override public void close() throws Exception { System.out.println("close"); } } public class Trial { public static void main(String[] args) { try (What w = new What()) { System.out.println(w.name); } catch (Exception e) { e.printStackTrace(); } } } ``` <br/> # <span style="color:#619BE4">super</span> ***** 父类引用 <br/> # <span style="color:#619BE4">.this</span> ***** 获取类实例 <br/> # <span style="color:#619BE4">.class</span> ***** 获取类类型 <br/> # <span style="color:#619BE4">() -> {}</span> ***** 匿名箭头函数 <br/>