title: How can i fix this method so it returns null if the car type is not found
body: <p>How can i fix this method so it returns null if the car type is not found?
  Im new to java so take it with a grain of salt</p>
  <pre><code>public static Car findCar (Car[] cars, String type) 
  { 
      if (cars.length == 0) 
          throw new java.lang.IllegalArgumentException (&quot;no cars&quot;); 
   
      
      Car    cheapestCar = cars[0]; 
      double  price = cheapestCar.getPrice (); 
      
      for (int i = 0; i &lt; cars.length; i++) 
          if (cars[i].getPrice() &lt; price &amp;&amp; 
              cars[i].getType().equals(type)) 
          { 
              cheapestCar = cars[i]; 
              price = cheapestCar.getPrice (); 
              
          } 
      
      return cheapestCar;
  } 
  </code></pre>