title: Compare objects contained in a map
body: <p>I have to do an exercise and I need a little bit of help.</p>
  
  <p>I have two objects called teacher1 and teacher2 with the attributes name and age:</p>
  
  <pre><code>Teacher teacher1 = new Teacher();
  Teacher teacher2 = new Teacher();
  teacher1.newTeacher("David", 26);
  teacher2.newTeacher("Douglas", 26);
  </code></pre>
  
  <p>newTeacher is a constructor of the class Teacher, contained in another class called Teacher.class, that contains</p>
  
  <pre><code>public class Teacher {
  
  String name;
  int age;
  
      public void newTeacher(String n, int a) {
          name = n;
          age = a;
      }
  
      public String getName() {
          return name;
      }
  
      public int getAge() {
          return age;
      }
  }
  </code></pre>
  
  <p>I have to put each one in a different Map with a String as key:</p>
  
  <pre><code>HashMap&lt;String, Object&gt; map1 = new HashMap&lt;String, Object();
  HashMap&lt;String, Object&gt; map2 = new HashMap&lt;String, Object();
  map1.put("123A",teacher1);
  map2.put("456B",teacher2);
  </code></pre>
  
  <p>Then I have to access them from each Map and compare their attributes.</p>
  
  <p>Can you help me with this last step?</p>