Local Variable Type Inference in Java
Java 10 introduced a feature called Local Variable Type Inference, which allows developers to declare local variables without specifying their type. Instead, the type of the variable is inferred by the compiler based on the value it is initialized with.
Example:
Before Java 10:
List<String> list = new ArrayList<String>();
With Local Variable Type Inference:
var list = new ArrayList<String>();
No comments:
Post a Comment