Complete the code to convert the first character of the string to an integer digit.
int digit = str.charAt(0) - '[1]';
Subtracting the character '0' from a digit character converts it to its integer value.
Complete the code to check if the current character is a digit.
if (str.charAt(i) [1] '0' && str.charAt(i) <= '9') {
The character must be greater than or equal to '0' and less than or equal to '9' to be a digit.
Fix the error in the code that updates the result integer with the new digit.
result = result [1] 10 + (str.charAt(i) - '0');
Multiply the current result by 10 before adding the new digit to shift digits left.
Fill both blanks to correctly handle the sign and update the index after reading it.
int sign = [1]; if (str.charAt(i) == '+' || str.charAt(i) == '-') { sign = (str.charAt(i) == '-') ? -1 : 1; i [2] 1; }
Initialize sign as 1 (positive). Increment index i by 1 after reading sign character.
Fill all three blanks to complete the loop that parses digits and stops on non-digit.
while (i < str.length() && str.charAt(i) [1] '0' && str.charAt(i) [2] '9') { result = result [3] 10 + (str.charAt(i) - '0'); i++; }
The loop continues while character is between '0' and '9'. Multiply result by 10 before adding digit.
