This works fine:
int foo = bar.charAt(1) - '0';
Yet this doesn't - because bar.charAt(x) returns a char:
int foo = bar.charAt(1);
It seems that subtracting '0' from the char is casting it to an integer.
Why, or how, does subtracting the string '0' (or is it a char?) convert another char in to an integer?
'0' == 0
. In reality,'0' == 48
. – Kirman