title: Printing select sections of an array list if a condition is met
body: <p>I'm writing a program that allows the user to check dogs into a kennel and I'm having some trouble printing all of the dogs that like bones (one of the criteria in the arraylist when you add a dog). I'm trying to print out just the name when you select the option "print all dogs who like bones" from the main console menu, but it's printing out all information from the array list.</p>
  
  <p>Here's the current code:</p>
  
  <pre><code>private void printDogsWithBones() {
  
      Dog[] dogsWithBones = kennel.obtainDogsWhoLikeBones();
      System.out.println("Dogs with bones: ");
  
      for (Dog d: dogsWithBones){
          System.out.println(d);
      }   
  }
  
  public Dog[] obtainDogsWhoLikeBones() {    
      // TODO
      // Prints "null" if a dog is in the array that doesn't like bones.
  
      Dog[] tempResult = new Dog[dogs.size()];
      // Sets the int tempResult to -1 to allow for scanning through the array from position 0, making sure every dog is accounted for.
      int tempCount = -1;
  
      // For each loop to scan through the array and check for each dog that likes bones
      for (Dog t : dogs){
          // Adds 1 to tempCount to enable efficient and functional scanning through the array
          tempCount++;
          // Adds the animal from the array to the temp Array which will then be printed back in KennelDemo
          if(t.getLikesBones() == true){
              tempResult[tempCount] = t;
          }
      }
      return tempResult;
  }
  </code></pre>
  
  <p>Another issue I'm having is that if the dog doesn't like bones, it prints out "null" instead of nothing at all. </p>
  
  <p>Here's what the console prints out when the method is ran:</p>
  
  <pre><code>1 -  add a new Dog 
  2 -  set up Kennel name
  3 -  print all dogs who like bones
  4 -  search for a dog
  5 -  remove a dog
  6 -  set kennel capacity
  q - Quit
  What would you like to do:
  3
  Dogs with bones: 
  null
  Dog name:RoverLikes Bones?:trueOriginal Owner:[David         98765]Favfood:NipplesFoodPerDay:3
  Dog name:IzzyLikes Bones?:trueOriginal Owner:[Jay 123456789]Favfood:CurryFoodPerDay:3
  </code></pre>
  
  <p>Thanks in advance everyone.</p>