Re: why String s = new String("test") is bad?



On Thu, 30 Oct 2008 10:59:40 -0700 (PDT), Steve <javacc2@xxxxxxxxx>
wrote, quoted or indirectly quoted someone who said :

I always wonder why String s = new String("test") is bad?

We always do String s = "test" instead. Why?

Please help explain. thanks!!

see http://mindprod.com/jgloss/newbie.html
http://mindprod.com/jgloss/string.html

The first creates a duplicate string object, wasting RAM.
--
Roedy Green Canadian Mind Products
http://mindprod.com
A vote for McCain is fearful clinging to McSame.
A vote for Obama is a shot at Obamalot.
.



Relevant Pages

  • Re: Fastcode Voting - IntToStr Result Length Rule
    ... > Please rephrase the rule suggestions and vote. ... to our benchmark) that does the specified job within the specified ... Allocate result string of needed length exactly. ...
    (borland.public.delphi.language.basm)
  • Re: NBC: Bush as the new Saddam
    ... three explanations: ... I can't believe you wasted your vote on a man who is not even smart enough ... to string together a few sentences. ... Bill Longyard ...
    (rec.music.artists.springsteen)
  • Re: More US bashing ?
    ... responsible for 99% of crime being allowed to vote. ... string them up from the nearest tree, rather than give them the vote, ... I'd prefer to return America to an ethnology ...
    (rec.autos.sport.f1)
  • Re: how to insert space in a string
    ... The basic technique is to scan the string, char by char, and depending ... A vote for McCain is fearful clinging to McSame. ... right, the method indexOf is exactly what I need, and thx Mark for ...
    (comp.lang.java.programmer)
  • Re: Fastcode Voting - IntToStr Result Length Rule
    ... > Please rephrase the rule suggestions and vote. ... Allocate result string of needed length exactly. ... Allocate result string of length according our global rule ...
    (borland.public.delphi.language.basm)