Originally posted by Mr. C Lamont Gilbert:
AFAIK, only literals are interned. I was not aware that constants would be interned automatically.
I don't think that is interned!?
No, it won't, but it is not a constant. Yes, all constants are interned. It is important to point out that in previous posts, the term 'compiler' refers to javac and not the runtime compiler, which may well (and often does) make the optimisations that are being asked about. It does this by
reasoning that the type is 'immutable' (has only referentially transparent operations). In the case of String, the reasoning is shortcut by the simple fact that String is a compiler primitive.