March 2019
Intermediate to advanced
242 pages
6h 21m
English
As of Java 10, var is a restricted local variable type and cannot be used for type declarations. Code that uses var as the name of a class, interface, method, method parameters, or variables, will no longer compile in JDK 10 and later releases.
The following is an example of code that uses var at multiple places and won't compile:
class var {} // can't use var as class nameinterface var {} // can't use var as interface nameclass Demo { int var = 100; // can't use var as instance variable // name static long var = 121; // can't use var as static variable // name void var() { // can't use var as method name int var = 10; // cant use var as the name of a local // variable } void aMethod(String var) {} // can't ...Read now
Unlock full access