title: Why StartsWith is returning me a wrong item
body: <p>I'm using the method <code>String.startsWith</code> to compare 2 strings to see if one of them begins with the introduced characters.</p>
  
  <p><strong>CODE</strong></p>
  
  <pre><code>List&lt;Province&gt; models;
  
  public int getIndexIfStartsWith(String str){
  
      for(int index = 0; index &lt; models.size(); index++){
          if(str.startsWith(models.get(index).getKey())){
              return index;
          }
      }
      return -1;
  }
  </code></pre>
  
  <p>I'm comparing against a list of provinces of Spain. If I put <code>14006</code> as a string to compare, the method iterate against a list of provinces with <code>key</code> (a number like "1", "28", etc) and <code>value</code> (name of province).</p>
  
  <p>When I enter <code>14006</code> the method returns me the item <code>"1", "ALAVA"</code>, but "1" is not the same of "14" that is the begging of the compared value. ALAVA with a key length of 1, shouldn't be compared against "14" (the begging of the desired value).</p>
  
  <p>Whats wrong??</p>
  
  <pre><code>compare 14006 against 1, ALAVA
                        2, ALBACETE
                        3, ALICANTE
                        ...
                        14, CORDOBA
  </code></pre>
  
  <p>Córdoba, 14006 should be the only match, but Alava is returned too.</p>
  
  <p>I'm using this for left padding the number with zeros, so I can compare everytime against 2 digits.</p>
  
  <pre><code>public static String padLeft(String stringToPad, int padToLength){
      String retValue = null;
      if(stringToPad.length() &lt; padToLength) {
          retValue = String.format("%0" + String.valueOf(padToLength - stringToPad.length()) + "d%s",0,stringToPad);
      }
      else{
          retValue = stringToPad;
      }
      return retValue;
    }
  </code></pre>
  
  <p>later, with this I use...</p>
  
  <pre><code>public int getIndexIfStartsWith(String str){
  
      for(int index = 0; index &lt; models.size(); index++){
          if(str.startsWith(CommonUtils.padLeft(models.get(index).getKey(), 2))){
              return index;
          }
      }
      return -1;
  }
  </code></pre>