You're storing the individual digits as chars. Chars are basically a subset of int, and their values map to ints that have little to do with the character they represent. So when you call:
new Integer (S.charAt(i))
What you're actually getting is the int that represents the char, not the actual char. It can be a bit confusing, so I recommend you write a little test program that prints out char values and the int values underlying them.
But to fix your problem, you want to convert the char to a String first.
Recommended reading: Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)