to get last char use mark.getCharAt(mark.lenght-1) . it's much readable and  effective (constant memory/speed instead of linear).