Set<Long> idsSet = new HashSet<Long>();
//过滤没有详情的id
for(Entry<Long, UserProfile> entry : userProfileMap.entrySet()){
UserProfile userProfile = entry.getValue();
if (userProfile == null) {
continue;
}
idsSet.add(userProfile.getUserId());
}
Long[] idsLong = idsSet.toArray(new Long[0]); //long[]转为Long[]
int idsLen = idsLong.length;
long[] idslong = new long[idsLen]; //分配空间
for(int i = 0; i < idsLen; i++){ //把Long[]转为long[]
idslong[i] = idsLong[i];
}
long a = new Long(0); //非数组转换不需要考虑空间问题,数组转换则需要分配空间,如上