list转为 数组[] 形式

list 转为数组[] 形式

1:String类型

ArrayList<String> temp = new ArrayList<>();
String[] stringtemp = temp.toArray(new String[temp.size()])

2:int类型

  • 这个是 JDK8 的特性
int[] result999 = result.stream().mapToInt(Integer::intValue).toArray();

猜你喜欢

转载自blog.csdn.net/weixin_44412864/article/details/113838005