I have this code :
private void submitPstart() {
if (tStock.getText().charAt(0)>=\'A\' && tStock.getText().charAt(0)<=\'Z\'){
}else
You need to check if getText()
returns a 0-length (i.e. empty) string.
If it does, then don't try to pull the first character out! (via charAt()
)
Note that your commented-out check for length()
should occur prior to the existing character check.
You may want to check for a null string being returned as well, depending on your framework/solution etc. Note the Apache Commons StringUtils.isEmpty() method, which performs this check concisely.