Re: How equals method works in StringBuffer?
- From: Jeffrey Schwab <jeff@xxxxxxxxxxxxxxxx>
- Date: Thu, 31 Aug 2006 12:44:01 GMT
Chris Smith wrote:
<swornavidhya_m@xxxxxxxxxxx> wrote:Hai,
In my following code, the output i obtained is: false. Whereas
my expectation for output is true. I need ur suggestions and ideas.
StringBuffer's equals method returns true only when a StringBuffer object is compared with itself. It returns false when compared with any other StringBuffer, even if the two contain the same characters. This is actually quite a sensible behavior.
Chris, would you mind elaborating a little? I would have expected:
sb1.equal(sb2) == sb1.toString().equal(sb2.toString())
.
- Follow-Ups:
- Re: How equals method works in StringBuffer?
- From: Oliver Wong
- Re: How equals method works in StringBuffer?
- From: Patricia Shanahan
- Re: How equals method works in StringBuffer?
- References:
- How equals method works in StringBuffer?
- From: swornavidhya_m
- Re: How equals method works in StringBuffer?
- From: Chris Smith
- How equals method works in StringBuffer?
- Prev by Date: LimpidLog 1.00 released
- Next by Date: Re: Servlets, send redirect and request scope
- Previous by thread: Re: How equals method works in StringBuffer?
- Next by thread: Re: How equals method works in StringBuffer?
- Index(es):