string buffer query

why equals method is not overridden for StringBuffer class?
[66 byte] By [balaji31a] at [2007-10-3 2:54:24]
# 1
> why equals method is not overridden for StringBuffer> class?Good question. I don't know. Maybe they forgot it.
CeciNEstPasUnProgrammeura at 2007-7-14 20:43:28 > top of Java-index,Java Essentials,Java Programming...
# 2
correct they might have forgot it . Since its programmitically so intutive to have overridden equals method inside StringBuffer just like Integer ,it should ahve come in later versions .
balaji31a at 2007-7-14 20:43:28 > top of Java-index,Java Essentials,Java Programming...
# 3

> correct they might have forgot it . Since its

> programmitically so intutive to have overridden

> equals method inside StringBuffer just like Integer

> ,it should ahve come in later versions .

It would have been intuitive indeed, that's why I think it's somewhat of a design flaw. But it won't be retrofitted, since StringBuffer is defined to use Object.equals(), and you can't change that now. It would break backwards-compatibility.

Suddenly StringBuffer a = new StringBuffer();

StringBuffer b = new StringBuffer();

System.out.println(a.equals(b));

would return true instead of false.

CeciNEstPasUnProgrammeura at 2007-7-14 20:43:28 > top of Java-index,Java Essentials,Java Programming...
# 4
yes you are correct .. I haven't thought of backward-compatibility . So we have to live with this ...
balaji31a at 2007-7-14 20:43:28 > top of Java-index,Java Essentials,Java Programming...