Suppose, I have a class with a constant static final field. Then I want in certain situations that field to be different. It still can be final, because it should be initialized in constructor. My question is, what strategy I should use:
- add this field value into the constructor
- create 2 subclasses, replace original field usage with some protected method and override it in subclasses
- Or create some composite class that will held instance of my class inside and somehow change that value?
Which approach should I use and why?
static final
, if you want to set a new value into thestatic final
permanently to be used from that point on, or to do something else.