Being "immutable" is actually the opposite of what you describe; it means the object cannot be changed after creation or added to.
Regardless, this has nothing to do with immutability. There is no way to emulate that construction for your own classes. String literals are part of the bare bones specification of the language. Just like we have no operator overloading in Java (and thus have no way to make the compiler interpret +
the way we'd like it to), we have no way to make the compiler understand a different set of literals. They just are what they are.
I'm sure there is some brilliant way to modify the JVM and create your own compiler to do what you want, but then you're not really using Java anymore.
You can read more about literals in the JLS 3.10, or the official Oracle tutorials (this one for String
s, this one for actual primitive types).