[gclist] Garbage collection and XML

Ken Anderson kanderson@bbn.com
Wed, 07 Mar 2001 09:39:57 -0500


At 11:57 PM 3/6/2001 , David Chase wrote:
>At 05:07 PM 3/6/2001 -0800, Bryan O'Sullivan wrote:
>
>final public class U {
>   public static String u(String s) { return new String(s.intern()); }
>}
>
>.... U.u("a string") ...
>
>Less typing than those clunky old Modula-3 keywords :-).
>

Unfortunately, the String() constructor copies the underlying char[].
I think this will work the way you intended.

final public class U {
  public static String u(String s) { return s.intern(); }}