public class Test
{
public static void main(String[] agrs)
{
int[] array = {1, 2, 3, 4, 5};
String x = Arrays.toString(array);
System.out.println(x);
}
}
能不能将x变成array数组?
------解决方案--------------------
当然可以,你看下Arrays.toString源码就知道,就是简单封装了下而已
------解决方案--------------------
可以的
public static void main(String[] agrs)
{
int[] array = {1, 2, 3, 4, 5};
String x = Arrays.toString(array);
System.out.println(x);
String numString = x.substring(1, x.length()-1).replaceAll("\\s+", "");
String[] ob = numString.split(",");
for(String str:ob)
{
System.out.println(str);
}
}