0
class R2
{
	final int t;
	void doit(){
		t=7;
	}
}

Blank finals allow us to declare a final variable without explicitly initializing it. We can initialize it only once later. Then, why is th above code not working ?

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by daudiam
0

A blank final var must be initialised in all constructors - ie it must have a value by the time the containing instance has been initialised.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.