class="java" name="code">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]); int idsLen = idsLong.length; long[] idslong = new long[idsLen]; for(int i = 0; i < idsLen; i++){ idslong[i] = idsLong[i]; }