Are runtime strings still imutable ?

From: Rob Jones (nospam_at_dontbother.com)
Date: 03/31/04


Date: Wed, 31 Mar 2004 17:52:32 +0100

Hi all,

Anyone know the details about String immutability ?

I understand the need to have imutable strings at compile time.
However if at runtime I have say 8000 strings and then I make
a new string from an existing string using substring
does that mean that my exisint 8000 strings will be searched
incase I am making a duplicate ?
That seems quite an overhead ?

Equally once I have created this new String once it becomes
eligible for garbage collection will the immutable String
be removed from the immutable string collection ?
IE will I just lose a reference to an immutable String object
or will that immutable String object be resuable for new
String objects that are created to have the same value ?
Does that mean creating/deleting lots of Strings can build
up an unfreeable area of memory ?

Thanks

Rob



Relevant Pages

  • Re: Why doesnt Integer have a setValue(int i), and is there a way of changing its value.
    ... The alternative to immutability would ... password "guest" as Strings to some function and then at some later ... username String to "root". ... this has the potential of being a security problem. ...
    (comp.lang.java.programmer)
  • Re: programming concepts > specific languages
    ... >> On the second line, the value of the reference is passed along, not the ... >the string, and performs a therefore useless manipulation of it. ... Immutability of objects is, AFAIK, implemented simply by not providing ... myString *which is a reference to a String object*, ...
    (comp.programming)
  • Re: Why String is Immutable?
    ... >>> secret behind Java's very fast substring implementation.'' ... It seems to me that a mutable string could exhibit ... >>>this these as advantages of immutability. ...
    (comp.lang.java.programmer)
  • Re: Are runtime strings still imutable ?
    ... Rob Jones wrote: ... > Anyone know the details about String immutability? ... > IE will I just lose a reference to an immutable String object ... This is not exactly what immutability means. ...
    (comp.lang.java)
  • Re: Datasets? Properties? Values?
    ... There's nothing special about string here. ... >> immutable object, like any other immutable object one could design. ... > passed by its value of the pointer to its starting adres and by a change get ... The immutability just means there ...
    (microsoft.public.dotnet.languages.vb)