- Java 11 and 12:New Features
- Mala Gupta
- 105字
- 2021-07-02 12:26:58
Compulsory non-null initialization
A local variable defined with var must be initialized with its declaration, or the code won't compile. The compiler can't infer the type of an uninitialized variable or a variable that is assigned a null value. The following code won't compile:
var minAge; // uninitialized variable var age = null; // variable assigned a null value
The following image illustrates what would happen if the uninitialized variable age went to seek entrance to the Mr. Java compiler place. The compiler won't let age in:

Variable definition using var must always be accompanied by its initialization, or the code will fail to compile.
推薦閱讀
- .NET之美:.NET關鍵技術深入解析
- Apache ZooKeeper Essentials
- SQL Server 2012數據庫技術及應用(微課版·第5版)
- Three.js開發指南:基于WebGL和HTML5在網頁上渲染3D圖形和動畫(原書第3版)
- Python編程完全入門教程
- Data Analysis with IBM SPSS Statistics
- TypeScript圖形渲染實戰:基于WebGL的3D架構與實現
- Windows Server 2012 Unified Remote Access Planning and Deployment
- Android開發案例教程與項目實戰(在線實驗+在線自測)
- HTML5+CSS3 Web前端開發技術(第2版)
- Regression Analysis with Python
- Modern C++ Programming Cookbook
- Java并發編程:核心方法與框架
- Exploring SE for Android
- 現代C:概念剖析和編程實踐