JDK 1.5 ~ 21까지의 주요 문법 예시 코드로, 주요 내용은 노션에서 볼 수 있습니다.
- JDK 21 문법은 현재(2023.12.09) preview 기능들이기에 정식 지원하지 않는 기능들이 있습니다.
- 해당 기능들은 아래와 같이 터미널에서 실행해보시길 바랍니다.
- 우선, Java 21이 설치되어 있어야 합니다.
- asdf 사용 시 :
asdf install java openjdk-21
- asdf 사용 시 :
- 컴파일 방법
javac --release 21 --enable-preview {컴파일할 클래스 명}.java
- 실행 방법
java --enable-preview --source 21 {컴파일할 클래스 명}.class
- StringTemplates
- Sequenced Collections
- Unnamed Patterns and Variables (Preview)
- Unnamed Classes and Instance Main Methods (Preview)
- Virtual Threads (Preview)
- Structured Concurrency (Incubator)
- Record Patterns (Preview)
- Code Snippets in Java API Documentation
- Deprecate Finalization for Removal
- Pattern Matching for switch (Preview)
- Sealed Class (Preview)
- Records (개선)
- Pattern Matching for instanceof (개선)
- Records (Preview)
- Pattern Matching for instanceof (Preview)
- NullPointerExceptions 개선
- Text Blocks : Multiline Strings (Preview)
- Switch Expression 개선 (Preview)
- Switch Expression 확장 (Preview)
- HTTP Client
- Local-Variable Syntax for Lambda Parameters(Lambda 파라미터로 var 사용)
- File API 개선
- String API 개선
- Local-Variable Type Inference (var 키워드)
- JPMS : Java 9 Platform Module System
- Try-With-Resources 개선
- Stream API 추가
- JShell (대화형 쉘)
- Interface Private Method
- Stream API
- null 대신 Optional
- Date & Time API
- Base64 인코딩과 디코딩을 위한 표준 API
- Parallel Array Sorting (병렬 배열 정렬)
- Default Methods in Interface
- 메서드 참조 (Method Reference)
- Functional Interface
- Automatic resource management in try-statement
- Allowing underscores in numeric literals
- Binary integer literals
- Diamond Operator
- Strings in switch
- Annotation 기능 향상
- Improved semantics of execution for multi-threaded Java programs
- Varargs
- Enhanced for each loop
- Enumeration
- Generics
- Autoboxing / Unboxing