I can do this using an if statement but I feel like the code is too long for this simple operation.
num = -12345
-->inserts magical code<--
desired output
num_list = ['-1', '2', '3', '4', '5']
I can do this using an if statement but I feel like the code is too long for this simple operation.
num = -12345
-->inserts magical code<--
desired output
num_list = ['-1', '2', '3', '4', '5']
You can simply use .split("\\B")
So the magical code would be:
String[] num_list = Integer.toString(num).split("\\B");