title: Codingbat problems -- String
body: <p>I came across a question on codingbat and the question is: </p>
  
  <p>Given a string, return a new string made of 3 copies of the last 2 chars of the original string. The string length will be at least 2.
  I solved the problem and the solution (below) is a better than mine, however, there is a problem with the solution code, when the string length is less than 2, say the length is only 1. str index will be -1. will the code still work? why does the site say the solution is correct? </p>
  
  <pre><code> public String extraEnd(String str) {
        String end = str.substring(str.length()-2);
        return end + end + end;
  </code></pre>