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