Skip to content

Mikbac/Java-new-features

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

List of new Java functions with examples

Table of contents


Java 8 (LTS)

https://openjdk.java.net/projects/jdk8/

GA Date → March 2014

Premier Support Until →March 2022

Extended Support Until → December 2030

  • Files.lines() - Read all lines from a file as a Stream. Bytes from the file are decoded into characters using the UTF-8 charset. (https://openjdk.java.net/jeps/179) //todo

TO-DO


Java 9 (non-LTS)

https://openjdk.java.net/projects/jdk9/

GA Date → September 2017

Premier Support Until → March 2018

Extended Support Until → Not Available

TO-DO


Java 10 (non-LTS)

https://openjdk.java.net/projects/jdk/10/

GA Date → March 2018

Premier Support Until → September 2018

Extended Support Until → Not Available

TO-DO


Java 11 (LTS)

https://openjdk.java.net/projects/jdk/11/

GA Date → September 2018

Premier Support Until → September 2023

Extended Support Until → September 2026

  • Local-Variable Syntax for Lambda Parameters - "Allow var to be used when declaring the formal parameters of implicitly typed lambda expressions." (https://openjdk.java.net/jeps/323)
  • HTTP Client - "Standardize the incubated HTTP Client API introduced in JDK 9, via JEP 110, and updated in JDK 10." (https://openjdk.java.net/jeps/321)

Java 12 (non-LTS)

https://openjdk.java.net/projects/jdk/12/

GA Date → March 2019

Premier Support Until → September 2019

Extended Support Until → Not Available

  • Switch Expressions (Preview) - "Extend switch so it can be used as either a statement or an expression, and so that both forms can use either traditional case ... : labels (with fall through) or new case ... -> labels (with no fall through), with a further new statement for yielding a value from a switch expression." (https://openjdk.java.net/jeps/325)

Java 13 (non-LTS)

https://openjdk.java.net/projects/jdk/13/

GA Date → September 2019

Premier Support Until → March 2020

Extended Support Until → Not Available

  • Switch Expressions (Second Preview) - "Extend switch so it can be used as either a statement or an expression, and so that both forms can use either traditional case ... : labels (with fall through) or new case ... -> labels (with no fall through), with a further new statement for yielding a value from a switch expression." (https://openjdk.java.net/jeps/354)
  • Text Blocks (Preview) - "A text block is a multi-line string literal that avoids the need for most escape sequences, automatically formats the string in a predictable way, and gives the developer control over format when desired." (https://openjdk.java.net/jeps/355)

Java 14 (non-LTS)

https://openjdk.java.net/projects/jdk/14/

GA Date → March 2020

Premier Support Until → September 2020

Extended Support Until → Not Available

  • Records (Preview) - "Records provide a compact syntax for declaring classes which are transparent holders for shallowly immutable data." (https://openjdk.java.net/jeps/359)
  • Text Blocks (Second Preview) - "A text block is a multi-line string literal that avoids the need for most escape sequences, automatically formats the string in a predictable way, and gives the developer control over the format when desired." (https://openjdk.java.net/jeps/368)
  • Switch Expressions (Standard) - "Extend switch so it can be used as either a statement or an expression, and so that both forms can use either traditional case ... : labels (with fall through) or new case ... -> labels (with no fall through), with a further new statement for yielding a value from a switch expression." (https://openjdk.java.net/jeps/361)
  • Pattern Matching for instanceof (Preview) - "Pattern matching allows common logic in a program, namely the conditional extraction of components from objects, to be expressed more concisely and safely." (https://openjdk.java.net/jeps/305)

Java 15 (non-LTS)

https://openjdk.java.net/projects/jdk/15/

GA Date → September 2020

Premier Support Until → March 2021

Extended Support Until → Not Available

  • Text Blocks - "A text block is a multi-line string literal that avoids the need for most escape sequences, automatically formats the string in a predictable way, and gives the developer control over format when desired." (https://openjdk.java.net/jeps/378)
  • Records (Second Preview) - "Records provide a compact syntax for declaring classes which are transparent holders for shallowly immutable data." (https://openjdk.java.net/jeps/384)
  • Sealed Classes (Preview) - "Sealed classes and interfaces restrict which other classes or interfaces may extend or implement them." (https://openjdk.java.net/jeps/360)

Java 16 (non-LTS)

https://openjdk.java.net/projects/jdk/16/

GA Date → March 2021

Premier Support Until → September 2021

Extended Support Until → Not Available

  • Pattern Matching For instanceof - "Pattern matching allows common logic in a program, namely the conditional extraction of components from objects, to be expressed more concisely and safely." (https://openjdk.java.net/jeps/394)
  • Records - "Records provide a compact syntax for declaring classes which are transparent holders for shallowly immutable data." (https://openjdk.java.net/jeps/395)

Java 17 (LTS)

https://openjdk.java.net/projects/jdk/17/

GA Date → September 2021

Premier Support Until → September 2026

Extended Support Until → September 2029

  • Pattern Matching for switch (Preview) - "Extending pattern matching to switch allows an expression to be tested against a number of patterns, each with a specific action, so that complex data-oriented queries can be expressed concisely and safely." (https://openjdk.java.net/jeps/406)
  • Sealed Classes - "Sealed classes and interfaces restrict which other classes or interfaces may extend or implement them (https://openjdk.java.net/jeps/409)

Java 18 (non-LTS)

https://openjdk.java.net/projects/jdk/18/

GA Date → March 2022

Premier Support Until → September 2022

Extended Support Until → Not Available


Java 19 (non-LTS)

https://openjdk.java.net/projects/jdk/19/

GA Date → September 2022

Premier Support Until → March 2023

Extended Support Until → Not Available


Java 21 (LTS)

GA Date → September 2023

Premier Support Until → September 2028

Extended Support Until → September 2031

  • Sequenced Collections - Introduce new interfaces to represent collections with a defined encounter order. Each such collection has a well-defined first element, second element, and so forth, up to the last element. (https://openjdk.org/jeps/431)
  • Record Patterns - Enhance the Java programming language with record patterns to deconstruct record values. Record patterns and type patterns can be nested to enable a powerful, declarative, and composable form of data navigation and processing. (https://openjdk.org/jeps/440)
  • Pattern Matching for switch - "Enhance the Java programming language with pattern matching for switch expressions and statements. Extending pattern matching to switch allows an expression to be tested against a number of patterns, each with a specific action, so that complex data-oriented queries can be expressed concisely and safely." (https://openjdk.org/jeps/441)
  • Virtual Threads - "Introduce virtual threads to the Java Platform. Virtual threads are lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications." (https://openjdk.org/jeps/444)
  • String Templates (Preview) = "Enhance the Java programming language with string templates. String templates complement Java's existing string literals and text blocks by coupling literal text with embedded expressions and template processors to produce specialized results" (https://openjdk.org/jeps/430)

Java 22 (non-LTS)

https://openjdk.java.net/projects/jdk/22/

GA Date → March 2024

Premier Support Until → September 2024

Extended Support Until → Not Available

  • Unnamed Variables & Patterns - unnamed variables and unnamed patterns, which can be used when variable declarations or nested patterns are required but never used. Both are denoted by the underscore character, _. (https://openjdk.org/jeps/456)

Java 23 (non-LTS)

https://openjdk.java.net/projects/jdk/23/

GA Date → September 2024

Premier Support Until → March 2025

Extended Support Until → Not Available

  • Markdown Documentation Comments - Enable JavaDoc documentation comments to be written in Markdown rather than solely in a mixture of HTML and JavaDoc @-tags. (https://openjdk.org/jeps/467)

Java 24 (non-LTS)

https://openjdk.java.net/projects/jdk/24/

GA Date → March 2025

Premier Support Until → September 2025

Extended Support Until → Not Available

  • Simple Source Files and Instance Main Methods (Fourth Preview) (https://openjdk.org/jeps/495)
  • Primitive Types in Patterns, instanceof, and switch (Second Preview) - Enhance pattern matching by allowing primitive types in all pattern contexts, and extend instanceof and switch to work with all primitive types. (https://openjdk.org/jeps/488)
  • Flexible Constructor Bodies (Third Preview) - In constructors in the Java programming language, allow statements to appear before an explicit constructor invocation, i.e., super(..) or this(..). The statements cannot reference the instance under construction, but they can initialize its fields. Initializing fields before invoking another constructor makes a class more reliable when methods are overridden. (https://openjdk.org/jeps/492)
  • Scoped Values (Fourth Preview) - Introduce scoped values, which enable a method to share immutable data both with its callees within a thread, and with child threads. Scoped values are easier to reason about than thread-local variables. (https://openjdk.org/jeps/487)
  • Module Import Declarations (Second Preview) - Enhance the Java programming language with the ability to succinctly import all of the packages exported by a module. (https://openjdk.org/jeps/494)
  • Structured Concurrency (Fourth Preview) - Simplify concurrent programming by introducing an API for structured concurrency. Structured concurrency treats groups of related tasks running in different threads as a single unit of work, thereby streamlining error handling and cancellation, improving reliability, and enhancing observability. (https://openjdk.org/jeps/499)

About

List of new Java functions with examples.

Topics

Resources

Stars

Watchers

Forks