var list = new ArrayList<String>(); // infers ArrayList<String>
var stream = list.stream(); // infers Stream<String>
var path = Paths.get(fileName); // infers Path
var bytes = Files.readAllBytes(path); // infers bytes[]
List<String> myList = Arrays.asList("a", "b", "c");
for (var element : myList) {...} // infers String
for (var counter = 0; counter < 10; counter++) {...} // infers int
try (var input =
new FileInputStream("validation.txt")) {...} // infers FileInputStream
**var** p = (String s) -> s.length() > 10; // error: lambda expression needs an explicit target-type
var arr = { 1, 2, 3 };
// error: array initializer needs an explicit target-type
reference
https://www.baeldung.com/java-10-local-variable-type-inference#illegal-use-of-var