title: Java: How do I create a getter method that gets an object from an inherited class?
body: <p>I'm trying to form a getter method of an object Mammal within a class Catalog.
  The get method has no parameters, and has a return type Mammal (?) </p>
  
  <pre><code>public class Mammal extends Animal {
      private double intellect;
      private double hitpoints;
  
      public Mammal(String firstName, String lastName, String nickname) {
          super(firstName, lastName, nickname);
      }
  
      public void setIntellect(double intellect) {
          this.intellect = intellect;
      }
  
      public void setHitpoints(double hitpoints) {
          this.hitpoints = hitpoints;
      }
      public double getIntellect() {
          return intellect;
      }
      public double getHitpoints() {
          return hitpoints;
      }
  </code></pre>
  
  <p>I know it's a pretty simple question and you didn't have to see that, just giving context.  I coded several classes like Mammal, such as Feline, Birds, etc. and am the last part of the assignment, Catalog, a series of get methods.  I just need to getMammal, getBirds, getFeline, and the return type is either Mammal, or Birds[], etc.  So the object itself or an array of objects. My attempt:</p>
  
  <pre><code>public class Catalogue{
      private Mammal mam;
  
      public getMammal() {
         Mammal mam = new Mammal();
         return mam;
      }
  }
  </code></pre>
  
  <p>so I'm clearly not understanding what to do at this step.  Any help would be appreciated!  The compile error I get is "invalid method declaration; return type required".  I'm trying it out in a few different ways, but can't seem to get past this error.</p>