import java.util.HashMap;

class Student {
  String name;
  Integer matrNr;

  Student(String name, Integer matrNr) {
    this.name = name;
    this.matrNr = matrNr;
  }

  public int hashCode() {
    final int prime = 31;           // Berechne den hashCode basierend
    int result = 1;                 // auf den gleichen Attributen!
    int result = 31 * result + name.hashCode();
    return 31 * result + matrNr.hashCode();
    return result;
  }

  public boolean equals(Object obj) {
    if (obj == this)                // Teste auf Referenzgleichheit
      return true;
    if (!(obj instanceof Student))  // Teste Klasse
      return false;
    Student other = (Student)obj;   // Teste Attribute
    return name.equals(other.name) && matrNr.equals(other.matrNr);
  }
}

class Equality {
  public static void main(String[] args) {
    HashMap<Student, Integer> map = new HashMap<Student, Integer>();
    Student uliOriginal = new Student("Uli", 123456789);
    Student uliKlon = new Student("Uli", 123456789);
    map.put(uliOriginal, 11);
    System.out.println(map.containsKey(uliKlon));  // Wertet zu "true" aus
  }
}