You are suffering from a char
overflow.
The main problem is with your loops...
for (char index = 0; index < ch.length; index++)
and
for (char index = (char) (ch.length-1); index >= 0; index--)
Which are using char
. Try changing them to use int
instead, for example...
for (int index = 0; index < ch.length; index++)
and
for (int index = (ch.length-1); index >= 0; index--)