官术网_书友最值得收藏!

Breaking existing code

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 name
interface var {} // can't use var as interface name
class 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 use var as the name of method parameter
}
It is important to test your production code with the latest Java release versions, even if you are not planning to deploy your production code to them. It will help to iron out any compatibility issues with your production code, helping to migrate it to a future version of Java.
主站蜘蛛池模板: 平江县| 汝州市| 呼伦贝尔市| 苏尼特右旗| 上栗县| 浠水县| 蓬莱市| 绥滨县| 唐海县| 晋州市| 泸州市| 资兴市| 焦作市| 普陀区| 隆尧县| 吴堡县| 婺源县| 卓尼县| 姚安县| 霞浦县| 资源县| 莱州市| 嵊泗县| 开远市| 阿拉善右旗| 如东县| 双流县| 永德县| 布尔津县| 闻喜县| 乌兰察布市| 淮安市| 茌平县| 登封市| 上蔡县| 鄄城县| 铜鼓县| 武平县| 长阳| 西宁市| 通江县|