- Java 11 and 12:New Features
- Mala Gupta
- 206字
- 2021-07-02 12:27:01
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.
推薦閱讀
- Modular Programming with Python
- LabVIEW 2018 虛擬儀器程序設計
- Processing互動編程藝術
- Mastering Yii
- Building a Quadcopter with Arduino
- Learning Salesforce Einstein
- Swift細致入門與最佳實踐
- 移動互聯網軟件開發實驗指導
- Hands-On Kubernetes on Windows
- Mastering AWS Security
- Python Machine Learning Blueprints:Intuitive data projects you can relate to
- ASP.NET Web API Security Essentials
- 數據分析與挖掘算法:Python實戰
- 分布式架構原理與實踐
- Mastering SciPy