Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以使用 if 语句来做到这一点,但我觉得代码对于这个简单的操作来说太长了。
数量 = -12345
-->插入神奇的代码<--
期望的输出
num_list = ['-1', '2', '3', '4', '5']
你可以简单地使用.split("\\B")
.split("\\B")
所以神奇的代码是:
String[] num_list = Integer.toString(num).split("\\B");