A string, string= "2324234535";
When the number I is taken out of the char type: char Temp=string.charat (i)
How do I convert the char type to int?
I need to find a sum of the mantissa, such as: 123 of the sum of the sum of 6.
Each character is taken out to obtain a char-type 1,2,3,4,5;
But the result of summing is the ASCII code value
Treatment methods:
(1) Turn char into a string, Integer.parseint ("" + ' 1 ')
Or
String a = "12345";
int d = integer.parseint (String.valueof (A.charat (2)));
int c = Integer.parseint (String.valueof (A.charat (3)));
System.out.println (d * c);
Demo
// [0..3] int start=integer.parseint (Drynoinfo.charat (1) + ""); // 0 int end=integer.parseint (Drynoinfo.charat (Drynoinfo.length ()-2) + ""); // 3 for (int i = start; I <=end; i++) { if (i>start) { sbuilder.append ( "|" ); } Sbuilder.append (i); }
(2) Chartoint can be directly used Character.digit (char ch, int radix);
http://tieba.baidu.com/p/2062701652
There are two methods of conversion:
One is an automatic conversion, such as char C = 97, which automatically converts 96 of the int type to the ' a ' of char
The other is to force the type conversion, such as int i = 97,char c = (char) I, after doing so, the value of char is also ' a '
Why is it a? Because the ASCII value corresponding to the character ' a ' is 97.
Automatic conversions are generally used for large types to small type conversions, also called narrowing conversions
Coercion type conversions are generally used for small type-to-large type conversions, also called extension conversions
How Java converts char data into int data (GO)