I’d like to add a method AddDefaultNamespace() to the String class in Java so that I can type 'myString'.AddDefaultNamespace() instead of DEFAULTNAMESPACE + 'myString', to obtain something like 'MyDefaultNameSpace.myString'. I don’t want to add another derived class either (PrefixedString for example).
Maybe the approach is not good for you but I personally hate using +. But, anyway, is it possible to add new methods to the String class in Java?
Thanks and regards.
Stringis a final class which means it cannot be extended to work on your own implementation.