Java-21 features

Index

  1. Language feauteres
    • String Template
    • record pattern
    • pattern matching for switch
  2. Libraries improvement
    • Virtual threads
    • Sequenced collections
  3. Performace improvement
    • ZGC


String Template[Preview]

Index

  1. Why Introduced
  2. syntax
    • Usage Example

There are three components to a template expression:

  1. A processor
    • STR Template Processor
  2. A template which contains the data with the embedded expressions
    • e,g, “\{var_name}
  3. A dot (.) character
String interpolationUsingSTRProcessor(String feelsLike, String temperature, String unit) {
    return STR
      . "Today's weather is \{ feelsLike }, with a temperature of \{ temperature } degrees \{ unit }" ;
}


Record pattern

Index

  1. Why Introduced
  2. syntax
    • Usage Example


Pattern matching for switch

Index

  1. Why Introduced
  2. syntax
    • Usage Example


Virtual threads

Index

  1. Why Introduced
  2. syntax
    • Usage Example

Sequenced collections

Index

  1. Why Introduced
  2. syntax
    • Usage Example

Published by

Unknown's avatar

sevanand yadav

software engineer working as web developer having specialization in spring MVC with mysql,hibernate

Leave a comment