Class VarInLambdaDemo

java.lang.Object
modernfeatures.java11.VarInLambdaDemo

public class VarInLambdaDemo extends Object
Demonstrates the use of var in lambda parameters introduced in Java 11. This includes examples of using var alone, with final, and with custom annotations on lambda parameters to enhance readability and enable static analysis or framework integrations.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    main(String[] args)
    Shows different ways to declare lambda parameters: - Traditional explicit type declaration - Using var keyword - Using final var to make the parameter effectively final - Using a custom annotation on the var parameter Each approach demonstrates how lambda parameters can be declared and annotated in Java 11 and beyond.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • VarInLambdaDemo

      public VarInLambdaDemo()
  • Method Details

    • main

      public static void main(String[] args)
      Shows different ways to declare lambda parameters: - Traditional explicit type declaration - Using var keyword - Using final var to make the parameter effectively final - Using a custom annotation on the var parameter Each approach demonstrates how lambda parameters can be declared and annotated in Java 11 and beyond.