When is it appropriate to use blank final variables?
问题 I was looking at another question about final variables and noticed that you can declare final variables without initializing them (a blank final variable). Is there a reason it is desirable to do this, and when is it advantageous? 回答1: This is useful to create immutable objects: public class Bla { private final Color color; public Bla(Color c) {this.color = c}; } Bla is immutable (once created, it can't change because color is final). But you can still create various Blas by constructing