📅  最后修改于: 2022-03-11 14:52:17.345000             🧑  作者: Mango
// First of all, you shouldn't use raw types.
// Use :
Set set = new HashSet<>();
set.add(4);
set.add(1);
// Then convert to array :
Integer[] arr = x.toArray(new Integer[set.size()]);
// Using x.toArray() would give you an Object[].