Re: Why String is Immutable?
- From: Tor Iver Wilhelmsen <jadedgamer@xxxxxxxxxxx>
- Date: 30 Sep 2005 18:22:19 +0200
Tim Tyler <tim@xxxxxxxxxxx> writes:
> That makes a String and then converts is to a StringBuffer
No, it take the interned String in the constant pool and creates a
StringBuffer using that.
> StringBuffer b = "It is clear what this means - but it doesn't compile";
Yes it is, except with a few more characters.
> It's also an example of Java's verbosity. I don't want to tell the
> compiler *twice* that I'm using a StringBuffer on the same line -
> it just makes Java code more painful and boring to read.
Ah, someone who feels C++'s confusing way of creating objects is good.
But in C++, too, you use "new classname()" when creating references.
> ...while being much neater and shorter.
If shortness is your goal, try PL/1 or J.
> Without it we'd be somewhere around: LET two = 1.plus(1);
Readability beats "writability" any day as long as you write something
that is supposed to be maintained later on, perhaps even by someone
else than you.
Do you comment your code? If so, why?
.
- References:
- Why String is Immutable?
- From: Bharath Ganesh
- Re: Why String is Immutable?
- From: Roedy Green
- Re: Why String is Immutable?
- From: Tim Tyler
- Re: Why String is Immutable?
- From: Tor Iver Wilhelmsen
- Re: Why String is Immutable?
- From: Tim Tyler
- Re: Why String is Immutable?
- From: Tor Iver Wilhelmsen
- Re: Why String is Immutable?
- From: Tim Tyler
- Why String is Immutable?
- Prev by Date: a swing component on top of another
- Next by Date: Identifying Animated GIFs
- Previous by thread: Re: Why String is Immutable?
- Next by thread: Re: Why String is Immutable?
- Index(es):
Relevant Pages
|