Fundamentals19 / 25
Up next

Local var inference

import java.util.List;

class Main {
    public static void main(String[] args) {
        // the compiler infers the static type; it is still strongly typed
        var count = 42;
        var name = "Ada";
        var nums = List.of(1, 2, 3);
        System.out.println(count + " " + name + " " + nums);
    }
}
What you're solving

var infers the type from the initializer