ArrayList.toString().replace(" ", ""); ArrayList 的 toString 输出的格式是 [1, 2, 3],只要把空格替换成空就可以了。数组的话也是类似的。