java - Making an array of ints from a String using charAt(i) gives me 2 digit numbers in each index? -


list s contains values 0000 5555. trying iterate through list , @ each index, charat(0), charat(1), charat(2) , charat(3) , put simple array of ints. how i'm trying achieve this:

for (int = 0; < s.size(); i++) {             (int j = 0; j < width; j++)                 currentguess[j] = integer.valueof(s.get(i).charat(j)); 

however, if use arrays.tostring(currentguess) result [48, 48, 48, 48] first iteration, , goes there, [48, 48, 48, 49] until [53, 53, 53, 53]. happening here?

48 ascii value of character '0'. if want convert digits respective numbers, need use (for example)

integer.valueof(s.get(i).charat(j) - '0'); 

Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -