Re: Why String is Immutable?



Brendan Guild sez:
> Tim Tyler wrote in news:Inu9Bw.D1u@xxxxxxxxxx:
>
>> Brendan Guild <dont@xxxxxxx> wrote or quoted:
>>> Tim Tyler wrote in news:InsoHw.FpG@xxxxxxxxxx:
>>> > Brendan Guild <dont@xxxxxxx> wrote or quoted:
>>> >> What mutable version of Double do you mean? [...]
>>
>>> > I mean double - as in:
>>> >
>>> > double d = 2.0;
>>> > d = d * d;
>>> >
>>> > I regard double variables as mutable.
>>> >
>>>
>>> [...] I certainly agree that double variables are mutable. I had
>>> considered that you might have meant double variables but rejected
>>> it because Double variables are also mutable in exactly the same
>>> way.
>>
>> java.lang.Double objects are immutable.
>
> I mean Double variables - as in:
>
> Double d = new Double(2.0);
> d = new Double(d.doubleValue() * d.doubleValue());
>
> I regard Double variables as mutable, considering this one started as
> 2.0 and ended up as 4.0.

Wow. I've got to add this to my signature collection.

Dima
--
.... If you want to make sure you don't put a Pig in a List of airplanes and
have it fail at insertion rather than extraction, use
planelist.add((Airplane)o) instead of planelist.add(o). It's that easy.
-- Mark 'Kamikaze' Hughes
.



Relevant Pages

  • Re: streams, etc
    ... |>as opposed to the extraction operator '>>', ... |>are extracting data from the stream. ... So now operand 2 gets written into ... | operand 1 and the result is operand 1, hence insertion. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: [PATCH][RT] 2.6.24-rc2-rt1 drivers/dma/ioat_dma.c compile fix
    ... I'm not positive about the insertion point... ... compile error fix (needs review) ... RT changes __list_splice to require prev and next pointers. ...
    (Linux-Kernel)
  • Re: Suppose: All code in header files?
    ... > Headers do not exist. ... the result of preprocessing the source texts. ... Whats the impetus behind the extraction and insertion/inclusion on the ... Is that insertion into the .cpp or ... ...
    (comp.lang.cpp)
  • Re: I Passed :-P
    ... > the roads each year form a working majority... ... > Of those who fail to get killed, how many never go near a road? ... Ian ... Prev by Date: ...
    (uk.rec.driving)
  • Re: Accessing next/prev element while for looping
    ... > for next2 in elts: ... > do_something_with (prev, cur, next) ... > Of course these fail when there's less than 3 elements. ... Prev by Date: ...
    (comp.lang.python)