title: Java - super reference
body: <p>So I want to add a toString() Method for a subclass of another class. How do I add super in it to incorporate the things already done by the superclass? 
  In my code you can see that I have  a class Person with several private variables, name, gender, and age. How do I use the toString method that was used in class Person into the toString method for the class Teacher? Thanks</p>
  
  <p>Here's my code:</p>
  
  <pre><code>class Person {
  
  protected String myName; // name of the person
  protected int myAge; // person's age
  protected String myGender; // "M" for male, "F" for female
  // constructor
  
  public Person(String name, int age, String gender) {
      myName = name;
      myAge = age;
      myGender = gender;
  }
  
  public String getName() {
      return myName;
  }
  
  public int getAge() {
      return myAge;
  }
  
  public String getGender() {
      return myGender;
  }
  
  public void setName(String name) {
      myName = name;
  }
  
  public void setAge(int age) {
      myAge = age;
  }
  
  public void setGender(String gender) {
      myGender = gender;
  }
  
  @Override
  public String toString() {
      return myName + ", age: " + myAge + ", gender: " + myGender;
  
  }
  }
  
  
  class Teacher extends Person {
  
  protected String mySubject; // Student Id Number
  protected double mySalary; // grade point average
  // constructor
  
  public Teacher(String name, int age, String gender,
          String subject, double salary) {
  // use the super class' constructor
      super(name, age, gender);
  // initialize what's new to Student
      mySubject = subject;
      mySalary = salary;
  }
  
  public String getSubject() {
      return mySubject;
  }
  public double getSalary() {
      return mySalary;
  }
  public void setSubject(String subject) {
      mySubject = subject;
  
  }
  public void setSalary(double salary) {
      mySalary = salary;
  }
  @Override
  public String toString() {
  
  }
  </code></pre>