【发布时间】:2016-09-18 18:07:07
【问题描述】:
我正在使用以下代码将 Set 转换为 int[]
Set<Integer> common = new HashSet<Integer>();
int[] myArray = (int[]) common.toArray();
我收到以下错误:
error: incompatible types: Object[] cannot be converted to int[]
在不使用 for 循环逐个添加元素的情况下进行转换的最干净的方法是什么?谢谢!
【问题讨论】:
-
在 StackOverflow 上终于找到了一个格式正确且语法正确的问题
标签: java data-structures collections set