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
Java strings are not null-terminated. Use String.length() to determine where to stop.
String.length()