Sometimes I'll see someone doing someChar - '0'
to get the integer value of a character. Why would they do that, instead of String.valueOf(someChar)
or Character.getNumericValue(someChar)
? The subtracting from 0 way looks so unintuitive and I don't even know how someone would figure out what it means without looking it up, unless they already had a good knowledge of ASCII encoding.