The compiler isn't that smart. We can tell that the value will always be 2. But what if we had something like this? class ABC{ final int a; public ABC(){ if(Math.random() < .5){ a = 2; } else{ a = 12345; } byte b = a; } } The constructor is not smart enough to tell these two cases apart, so it gives you an error instead.
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile