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");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.