// this code demonstrates the usage of two methods inherited from Class
// Object: toString() and equals()

public class StdMethods
{
   public static void main(String[] args)
   {
      StdMethodsTest c1 = new StdMethodsTest(5, "aaa");
      StdMethodsTest c2 = new StdMethodsTest(5, "bbb");
      System.out.println("c1: " + c1.toString());
      System.out.println("c2: " + c2.toString()); 

      if (c1.equals(c2))
        System.out.println("c1 = c2");
      else
        System.out.println("c1 != c2");
   }
}

// in this class we have two methods toString() and equals() that
// overwrite the corresponding methods in class Object
class StdMethodsTest
{
   private int a;
   private String s;
 
   public StdMethodsTest(int a, String s)     // class constructor
   {
      this.a = a;
      this.s = s;
   }

   public String toString()                   // printing the class vars
   {
      return "a=" + a + " s=" + s;
   }

   public boolean equals(StdMethodsTest o)    // comparing two instances of
   {                                          // this class for equality
      return (a == o.a) && (s.equals(o.s));
   }
}

