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 code may compile without error & run without throwing an exception, but converting between char's & int's is bad practice. First, it makes the code confusing, leading to maintenance headaches down the road. Second, clever "tricks" can prevent compilers from optimizing the byte code. One of the best ways to get fast code is to write dumb code (i.e., not clever code).