Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How does Java convert numeric characters in a numeric character array into integers?
How does Java convert numeric characters in a numeric character array into integers?
1, define a numeric string.

string str = " 1289898 ";

2. Declare an int array according to the length of the string.

int ia[]= new int[str . length()];

3. Loop the string and get the string through charAt.

for(int I = 0; I & ltstr. length (); i++){

char c = str . charat(I); //Get the characters in the string one by one.

}

4. Subtract the' 0' character from the obtained string C, which is the actual number.

for(int I = 0; I & ltstr. length (); i++){

char c = str . charat(I); //Get the characters in the string one by one.

ia[I]=(int)(c-' 0 '); //Number of Characters-The character 0 is the actual numeric value and is assigned to the numeric array.

}