Current Position:Home > Why StringBuffer does not override equals()

Why StringBuffer does not override equals()

Update:11-30Source: network consolidation
Advertisement
Is there any reason for StringBuffer to don't override equals()
Wargo

The Best Answer

Advertisement
Not that I can think of. I'd expect two StringBuffer instances to be considered equivalent (equal) if they both would hand me equivalent results from their toString() methods. Instead, I guess someone at Sun decided that identity was preferable to equivalence for this class's equals() method.
  • Why StringBuffer does not override equals() Update:11-30

    Is there any reason for StringBuffer to don't override equals() WargoNot that I can think of. I'd expect two StringBuffer instances to be considered equivalent (equal) if they both would hand me equivalent results from their toString() methods. Inste

  • Overriding equals and hashCode Update:11-30

    Everywhere I look it talks about overriding equals and hashCode together, and it also warns that doing it wrong could complicate things severly. However I haven't been able to find good documentation on how to do it properly. Any suggestions on where

  • Overriding equal() method Update:11-30

    Hi all, I am new to this forum.This is my first post. Please see below code... class One   private int a,b;        //we override equal() method  in this class public One(int x,int y)    a=x;    b=y; public boolean equals(Object o)      if((o instance

  • How do I safely and correctly override equals in a generic element class? Update:10-11

    (I posted this in the collection forum, but it was suggested I should take it here instead.) I've written an OrderedPair element class, (OrderedPair<K,V>), so I can have a set of ordered pairs. To get the container to treat OrderedPairs as values in

  • How to override equals method Update:11-30

    The equals method accepts Object as the parameter. When overriding this method we need to downcast the parameter object to the specific. The downcast is not the good idea as it is not the OO. So can anyone please tell me how can we override the equal

  • Problem in not overriding equals and Hashcode Update:11-30

    I have a very small question. We know that if we do not override the equals and hascode of Object class, we can not use the object in the Hashed collection. Can anybody provide me a concrete example which indicates the problem if we do not override t

  • Adding Objects To a HashSet, overriding equals and hashCode Update:11-30

    Hi everyone, I'm trying to add objects to a HashSet, using a string identifier (an attribute of these objects) to determine if two objects are equal. I have a class 'IntExpEvent' class that overrides the equals and hashCode methods. public class IntE

  • Need help overriding equals() method Update:11-30

    Hi I have an assignment where I have to override the equals() method, the thing that's bugging me though is my instructor says the parameter has to be Object. I understand you can pass anything through Object but if I want to get a method from the ob

  • Overrideing equals() and hashCode() Update:11-30

    This is related to my previous post. I have followed the advice that was given to me. I overrode equals() and hashcode() public class TwoTuple<A,B>{      public final A first;      public final B second;      public TwoTuple(A a, B b){           fir

  • Overriding equals(Object o) method Update:11-30

    hi, I have a problem in equals method ..returns true always... can anyone suggest whats wrong ? thanks for the help public  boolean equals(Object NumberC)             if (NumberC == null) return false;              if ( NumberC instanceof Counter)