int a = s.charAt(i);
...
if(s.chatAt(a)){
...
}

This is your problem as JAvaPF stated its an out of range exception. the reason for it is when you do this s.charAt(i); you are expecting a...