title: Sorting and printing only certain objects in an array with multiple class types, java
body: <p>My apologies for being horrible with the terminology...</p>
  
  <p>My program's parent class is Vehicle. Vehicle contains <strong>4 variables</strong>, <code>make</code> <code>model</code> <code>date</code> and <code>serial</code>. That class has <strong>two children</strong>, <code>Car</code> and <code>Boat</code>. <code>Car</code> has children <code>Truck</code> and <code>Van</code>, <code>Boat</code> has children <code>Powerboat</code> and <code>Sailboat</code>. Each of the children has its own specific set of variables. I have an array of type <code>Vehicle</code> which contains objects of type <code>Truck</code>, <code>Van</code>, <code>Sailboat</code> and <code>Powerboat</code>.</p>
  
  <p>My problem comes when I want to print only <code>Boat</code> objects. They need to be sorted by <code>boatLength</code>. I get error </p>
  
  <blockquote>
    <p>cannot find symbol</p>
  </blockquote>
  
  <p>in my sorting algorithm:  </p>
  
  <pre><code>  //regulates the first value
    for (int i = 0; i &lt; input.length-1; i++)
    {
       int min = i;
  
  
       //checks remaining values for min
       for (int j = i+1; j &lt; input.length; j++)
       {
          if (input[j].getBoatLength().compareToIgnoreCase(input[min].getBoatLength())&lt;0)
          {
              min = j;
          }  
       }
  
       //swaps values
       Vehicle temp = input[i];
       input[i] = input[min];
       input[min] = temp;
    }
  </code></pre>
  
  <p>Is there a way I can sort and print only the boat objects without creating an array for the Boat objects?</p>
  
  <p>here is the error message: </p>
  
  <pre><code>VehicleClient.java:276: error: cannot find symbol
              if (vehicles[i] instanceof Boat)
                  ^
    symbol:   variable vehicles
    location: class VehicleClient
  VehicleClient.java:310: error: cannot find symbol
              if (input[j].getBoatLength().compareToIgnoreCase(input[min].getBoatLength())&lt;0)
                          ^
    symbol:   method getBoatLength()
    location: class Vehicle
  VehicleClient.java:310: error: cannot find symbol
              if (input[j].getBoatLength().compareToIgnoreCase(input[min].getBoatLength())&lt;0)
                                                                         ^
    symbol:   method getBoatLength()
    location: class Vehicle
  3 errors
  </code></pre>