title: When to use type.length-1; and type.length(); in java
body: <p>I'm little bit confused when do I really need to use that length-1.  I know that is when we don't want to have out of bound error. For instance I wrote this simple array:</p>
  
  <pre><code>    int [] oldArray = {1, 5, 6, 10, 25, 17};
  
      for(int i = 0; i &lt; oldArray.length; i++){
  </code></pre>
  
  <p>It does not give me any error.  Any examples when -1 is actually useful? Thank you in advance.</p>