Is the behaviour, or even the very existence, of the string pool jvm implementation dependent?
I've seen several questions, where which answer is correct depends on the existence of a string pool.
For example, K&B6 p637 Q4, with a couple of comments added:
The size printed at line 15 is either 2 or 3, depending on whether line 25 is commented out.
The key point is line 23 where two "Monday" strings are tested for ==
However, if there were no string pool, the behaviour would be different. If I modify the class to ensure that the two "Monday" strings are different objects, then it doesn't matter if the line [a] is commented out or not. The size is always 3.
As far as I know, the string pool is exclusively implemented in pure java code so it shouldn't be jvm dependent. I don't see what could be implemented in native OS calls in there but I could be wrong. Anyway, I am sure at least most of it is implemented in pure java ;-)
I hadn't been here for fifteen years
Why is the word "abbreviation" so long? And this ad is so short?