How to convert a number in string to int digits in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {
 
    public static void main(String[] args) {
        
        String s = "746";
        
        for (int i = 0; i < s.length();i++)
        {
            char ch = s.charAt(i);
            int n = Character.getNumericValue(ch);
            
            System.out.println(n);
        }
    }
}
   
/*
run:
  
7
4
6
   
*/

 



answered Apr 2, 2017 by avibootz

Related questions

1 answer 112 views
2 answers 115 views
1 answer 164 views
1 answer 187 views
2 answers 163 views
4 answers 317 views
3 answers 247 views
...