I wrote this little function just for practice, but an exception (\"String index out of range: 29\") is thrown and I don\'t know why...
(I know this isn\'t the best
Looks like you are a C/C++ programmer coming to java ;)
Once you have gone out of range with .charAt (), it doesn't reach null, it reaches a StringIndexOutOfBoundsException. So in this case, you will need a for loop that goes from 0 to y.length()-1.