Why must a final variable be initialized before constructor completes?
public class Ex
{
final int q;
}
When I compile this code I get er
The language specification contains specific guarantees about the properties of final variables and fields, and one of them is that a properly constructed object (i.e. one whose constructor finished successfully) must have all its final instance fields initialized and visible to all threads. Thus, the compiler analyzes code paths and requires you to initialize those fields.