How could I split the numbers in the string "542" into individual digits? On my desktop I can split the numbers using String.split("")
and it works fine. But when run on Android, I get a NumberFormatException: Invalid int: ""
.
This is my code:
public void render(int n, SpriteBatch batch) {
String[] numbers = String.valueOf(n).split("");
for(int i = 0; i < numbers.length; i++)
batch.draw(Assets.numbers[0][Integer.valueOf(numbers[i])], pos.x + (50 * i), pos.y);
}
Is there an alternative way?