Type Inference with var in Java


Java 10 introduced the var keyword, allowing you to declare a local variable without specifying its type, thus making your code more concise and readable while retaining type safety.

Source Code

var list = new ArrayList(); // infers ArrayList
var stream = list.stream(); // infers Stream
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments