Hopefully a very simple query, but it\'s left me scratching my head.
I have a string, which is just a single integer, and I\'m trying to then get that integer out as
If the string is really 1
, the exception can't happen. So I would say the string is not actually 1
.
do a data.toCharArray()
and print each character's code (cast to int
). It may turn out that there is a hidden character before the digit, for example. (edit: it appears iluxa mentioned this option in a comment while I was writing the answer)
Try data = data.trim()
before passing it to parseInt(..)