If you look at it from the perspective of the new
operator it makes sense.
new
always allocates a new object. That goes for all classes across the board, no exception. It doesn't have any special case behavior for the String
class, nor any other class. It is completely class agnostic.
I don't see any need for an optimization to be added, either. Writing new String("literal")
is usually a mistake. Why bother speeding up a mistake?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…