Consider the following program and predict the output:
class Main {//from w w w .j av a2 s . c o m final Integer a; // #1 public void print(){ System.out.println("a = " + a); } public static void main(String[] args) { Main obj = new Main(); obj.print(); } }
a)
Every final variable must be initialized.
If a final variable is not initialized at the time of variable declaration (known as blank final), then it must be initialized in all the constructors of the class.
Since the final variable is not initialized in this class, the code results in a compiler error.