- 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.
推薦閱讀
- C#程序設(shè)計實訓(xùn)指導(dǎo)書
- PHP 從入門到項目實踐(超值版)
- Cross-platform Desktop Application Development:Electron,Node,NW.js,and React
- Learning SAP Analytics Cloud
- Windows Forensics Cookbook
- Drupal 8 Module Development
- 軟件測試技術(shù)指南
- Unity 5 for Android Essentials
- Access 2010數(shù)據(jù)庫應(yīng)用技術(shù)(第2版)
- Java Web開發(fā)詳解
- Getting Started with Python and Raspberry Pi
- jQuery技術(shù)內(nèi)幕:深入解析jQuery架構(gòu)設(shè)計與實現(xiàn)原理
- HTML5與CSS3權(quán)威指南
- 像程序員一樣使用MySQL
- Unity Certified Programmer:Exam Guide