title: Printing multiple objects in different classes
body: <p>The details in this example isn't that important just trying to figure out how I can solve this, I have 3 separate classes Person , Interests and Location. all are objects, a person would have an list of interests and each interest will have a list of locations, i'm using a toString to print my person object and the interest but I can't figure out how to print out the locations of each interest. Do i need to overload my toString?</p>
  
  <pre><code>public class Person{
      private String name;
      private ArrayList&lt;Interest&gt; interests = new ArrayList&lt;Interest&gt;();
  
      public Person(String name, ArrayList&lt;Interest&gt; interests) {
          this.name = name;
          this.interests = interests;
      }   
  
      public void addInterest(Interest newInterest) {
          interests.add(newInterest);
      }
  
      public Interest getInterest(int indexOfInterest) {
          return interests.get(indexOfInterest);
      }
  
      public ArrayList&lt;Interest&gt; getInterests() {
          return interests;
      }
  
      public String getName() {
          return name;
      }
  
      public String toString() {
          String result = getName() + " ";
          for(Interest interest : interests) {
              result += interest.getName() + "(" + interest.getDangerRating() + ")" + " ";
          }
          return result.trim();
      }
  }
  </code></pre>
  
  <p>//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////</p>
  
  <pre><code>public class Interest {
          private int dangerRating;
          private String name;
          private ArrayList&lt;Location&gt; location = new ArrayList&lt;Location&gt;();
  
      public Interest (int dangerRating, String name, ArrayList&lt;Location&gt; location) {
          this.dangerRating = dangerRating;
          this.name = name;
          this.location = location;
      }
      public int getDangerRating() {
          return dangerRating;
      }
      public String getName() {
          return name;
      }
  }
  </code></pre>
  
  <p>////////////////////////////////////////////////////////////////</p>
  
  <pre><code>public class Location {
      private String location;
      public Location (String location){
          this.location = location;
      }
      public String getLocation() {
          return location;
      }
  }
  </code></pre>