You have
for(int i = 0; i<origin.length();i++){
This should be
for(int i = 0; i<origin.length()-1;i++){
because in your substring, you are looking at i+1. You might want to consider using origin.charAt(i)
instead, this is the usual way to do it and you will not need to adjust your loop bounds. A substring will work fine with the modification to the loop, however. In addition, you might be trying to turn a character like the -
in -1
into an integer, maybe try-catch?