Since Java , you can use var instead of writing the type explicitly. The compiler figures out the type from the value you assign:
var count = 10; // compiler infers int
var price = 9.99; // compiler infers double
var name = "Alice"; // compiler infers String
The variable still has a fixed type. var count = 10; creates an int, and you can't later assign a String to count. The type is inferred at compile time, not at runtime.
There are limits. You can only use var with local variables (inside methods). You can't use it for method parameters, return types, or class fields. And you must assign a value immediately. var x; without a value won't compile because Java has nothing to infer from.