char to int type

A string, String = "1234567"; how to convert char to int
when the i-th number is taken out ?

First convert char to string type, then convert to int type

public static void main(String[] args) throws Exception
    {
        String a = "1234567";
        char b[] = a.toCharArray();
        for(int i=0;i<b.length;i++)
        {
            String c = String.valueOf(b[i]);
            int d = Integer.parseInt(c);
            System.out.print(d);
        }
    }

 The output result is 1234567

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324712884&siteId=291194637