8 Replies Latest reply on Apr 15, 2008 5:58 AM by sujikrishna

    do we have something like equals in Java?

    yevgen_78 Level 1

      for example i have a class MyClass. This class has only one variable 'var1';
      Now i want to have a method in my app to compare 2 Objects.

      public function compare( obj1:Object, obj2:Object):Boolean;

      Now i have 2 instances of the same varianbe
      var a1:MyClass = new MyClass( 12 );
      var a2:MyClass = new MyClass( 12 );

      how i can implement this compare method? I can't cast obj1 to myClass, because i have 20-30 differect classes. This is not the way.
      Do we have something like equals in Java? (in this case i must overwrite only this method in myClass)