tag:blogger.com,1999:blog-23939980.post114228822168894841..comments2023-09-25T17:29:29.440+10:00Comments on Java and other things: How useful is String(String) constructor?Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-23939980.post-17275851076862741262009-04-08T18:23:00.000+10:002009-04-08T18:23:00.000+10:00Nowadays also permgen space is garbage collected (...Nowadays also permgen space is garbage collected (Sun JVM). So string constants may be removed too.Betanoreply@blogger.comtag:blogger.com,1999:blog-23939980.post-54819017777301755482007-01-28T20:29:00.000+11:002007-01-28T20:29:00.000+11:00First of all, string constants are never garbage c...First of all, string constants are never garbage collected. Second of all, string constants are intern'd, which means they are shared across the entire VM. This saves memory. But it is not always what you desire.<br /><br />The copy constructor on String allows you to create a private String instance from a String literal. This can be very valuable for constructing meaningful mutex objects (for the purposes of synchronization).Anonymousnoreply@blogger.com