title: Has -A Relationship in java
body: <pre><code>public class Horse extends Animal {
      private Halter myHalter = new Halter();
      public void tie(LeadRope rope) {
          myHalter.tie(rope); // Delegate tie behavior to the
        // Halter object
      }
  }
  
  public class Halter {
      public void tie(LeadRope aRope) {
      // Do the actual tie work here
  }
  }
  </code></pre>
  
  <p>In this example Horse has-a Halter.Can we call <strong>myHalter.tie(rope);</strong> like this:</p>
  
  <pre><code>public class Horse extends Animal {
      private Halter myHalter = new Halter();
  
          myHalter.tie(rope); // Without using the public void tie method
  
  }
  </code></pre>
  
  <p>It gives an error. My explanation to this is that its not a main() method but could anyone explain it in a better way.</p>