Ok, I am trying to get the right three characters of a string in an Android app I’m writing.
Based on the research I’ve done in the SDK and online I should be able to use something like the following to do it.
millisecondsD = millisecondsD.substring(millisecondsD.length() -3, millisecondsD.length());
However, I get a force close whenever I try to use to use the code above. Am I just missing something super simple?
You may need to check to see that the string is at least 3 characters long and not
nullfirst.Also, you can leave off the second parameter if you want.
Example:
So, in this case the last 3 chars are 34, 33, and 32. The indices you have in your code are correct.