I typically place global compile-time variables (like constants that i use such as avogadro’s number or whatever) into public static final variables. However, i hadn’t ever considered if this actually does anything for Strings. Is there any point in making a String final since it’s already immutable?
It’s a theoretical more than a practical question.
finalis different from immutable.finalmeans the handler (variable) cannot point to another object. Immutable means the object can’t change its internal state.static final Foo foo = new Foo(1)means you can’t later havefoo = new Foo(2)Foois immutable, it means that once you create it, you can’t change its fields. E.g. you can’t haveFoo foo = new Foo(1); foo.setValue(3);