I know that one solution to do this is the following:
 String tmp = "12345";
      int result = 0;
      for (int i =0; i < tmp.length(); i++){
          char digit = (char)(tmp.charAt(i) - '0');
          result += (digit * Math.pow(10, (tmp.length() - i - 1)));
      }
      System.out.println(result);
What I don't understand is why is:
char digit = (char)(tmp.charAt(i) - '0');
How can this convert into a digit?
 
     
     
     
     
     
     
     
    