计算元素出现次数并存入map,急!

chaser401 chaser401 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我现在想要遍历数据库并记录id出现次数并存入map中,请问如何实现,我的方法:
while (rs.next()) {
radio = 0;
if (rs.getInt(''app_id'') != null) {
app_sum.put(rs.getInt("app_id"), app_sum.get(rs.getInt("app_id")) + radio);
count++;
app_day.put(rs.getInt("app_id"), count);
} else {
app_sum.put(rs.getInt("app_id"), radio);
app_day.put(rs.getInt("app_id"), 1);
count = 1;
}
}
如果结果无序的话会出问题,请问如何改进?
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
chaser401
Java SE 62,621 成员 307,251 内容