title: Last two letters of a user inputted string using substring (Java)
body: <p>I'm writing a program that generates star wars names. The user inputs their first, last, mother's maiden name, birth city, and first car and the program gives a star wars name. I need  the last two characters* of the user inputted last name. I know I can use <code>substring</code>, but I cannot get anything to work. The best I have is:</p>
  
  <pre><code>lastname.substring(lastname.length() -2)
  </code></pre>
  
  <p>which gives the first two letters of the last name, and not the last. Also, I cannot use <code>lastname.substr(-2)</code> because <code>substr</code> for some reason won't work (not sure why, this would be much easier). </p>
  
  <p>Thanks for any help. </p>
  
  <p>*EDIT: I hope I didn't confuse anyone, I need the last two characters of the last name. </p>
  
  <p>Actually I see my problem now: my original last name variable is </p>
  
  <pre><code>String lastname = console.nextLine().substring(0,2).trim().toUpperCase();
  </code></pre>
  
  <p>which keeps the first two letters, so the reason I was getting the first two letters was because of this. I understand now. Is there a way to get the last two letters from this same variable?</p>