How to access the second character in a three-digit int?

So you could parse it to a string and get the numbers that way like:

int num = ...;
string numbS = Integer.toString(num);
char char1 = numbS.charAt(0);
int num1 = Character.getNumericValue(char1);

Or you could do it by dividing by 10 and then the remainder of ten:

int digit2 = (num / 10) % 10;

Leave a Comment