In Java, once a String object is created, its characters can never change—calling s.toUpperCase() always allocates or returns a separate String while leaving s untouched. That single design choice enables safe String Pool sharing, cached hash codes, security and zero-effort thread safety.
More lessons in Complete Core Java