1、Set集合轉數組
// set集合
Set<Integer> idSet = new TreeSet<>();
idSet.add(data.getTypeId());
……
// 定義一個set長度的數組
Integer[] ids = new Integer[idSet.size()];
// set轉數組,執行完畢後返回數組,且ids數組存儲了set中的值
idSet.toArray(ids);
1、Set集合轉數組
// set集合
Set<Integer> idSet = new TreeSet<>();
idSet.add(data.getTypeId());
……
// 定義一個set長度的數組
Integer[] ids = new Integer[idSet.size()];
// set轉數組,執行完畢後返回數組,且ids數組存儲了set中的值
idSet.toArray(ids);