This works fine:
int foo = bar.charAt(1) - \'0\';
Yet this doesn\'t - because bar.charAt(x) returns a char:
int foo = bar.c
Your second snipped should work fine though:
int foo = bar.charAt(1);
A char, just like a short or byte, will always be silently cast to int if needed.
char
short
byte
int
This will compile just fine: int i = 'c';
int i = 'c';