Without spoon-feeding you the code:
The nth digit is the remainder after dividing (a divided by 10b-1) by 10.
return a / (int)Math.pow(10, b - 1) % 10;
See live demo.
If you want an iterative approach:
Loop b-1 times, each time assigning to the a variable the result of dividing a by 10.
After looping, the nth digit is the remainder of dividing a by 10.
while (--b > 0) {
a /= 10;
}
return a % 10;
See live demo.
--
FYI The remainder operator is %, so eg 32 % 10 returns 2, and integer division drops remainders, so eg 32 / 10 returns 3.