- 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.
推薦閱讀
- 極簡算法史:從數學到機器的故事
- 軟件界面交互設計基礎
- Learning ArcGIS Pro 2
- 樂高機器人設計技巧:EV3結構設計與編程指導
- Groovy for Domain:specific Languages(Second Edition)
- Web全棧工程師的自我修養
- Access 2016數據庫管
- NGINX Cookbook
- Illustrator CS6設計與應用任務教程
- Web Developer's Reference Guide
- 零基礎學C語言(升級版)
- Functional Python Programming
- Java EE互聯網輕量級框架整合開發:SSM+Redis+Spring微服務(上下冊)
- 計算機應用基礎
- Splunk Developer's Guide(Second Edition)