title: java method find max price
body: <p>My <code>findmaxprice</code> method returns the index of the first Car in the array with the maximum price. If it is not found, -1 is returned.</p>
  
  <p>As far as I know, <code>return</code> will stop the for loop.  Any advice on how to avoid it while keep the loop search for max price?</p>
  
  <pre class="lang-java prettyprint-override"><code>public int findmaxprice() {
      double max =0;
      for(int i =0; i &lt; nCars; i++) {
          if(max &lt;= Cars[i].getPrice()) {
              max = Cars[i].getPrice();
              return i; //the problem is here
          }   
      }
      return -1;
  }
  </code></pre>