循环遍历HashMap的较快方法
来源:互联网 发布:echo 数字数组 编辑:程序博客网 时间:2024/04/30 04:42
package MAIN;import Book.*;import java.util.*;public class slove {public static void main(String[] args) {Scanner in = new Scanner(System.in);int n = in.nextInt();String name; int val, num;HashMap<Book, Integer> str = new HashMap<Book, Integer>();for(int i = 0; i < n; ++i) {name = in.next();val = in.nextInt();num = in.nextInt();Integer second = Integer.valueOf(val) * Integer.valueOf(num);Book first = new Book(name, val, num);str.put(first, second);}int ans = getSum(str);System.out.println(ans);}public static int getSum(HashMap rhs) {int sum = 0;Iterator it = rhs.entrySet().iterator();while(it.hasNext()) {Map.Entry<Book, Integer> entry = (Map.Entry<Book, Integer>)it.next();Integer value = entry.getValue();sum += (int)value;}return sum;}}
0 0
- 循环遍历HashMap的较快方法
- java HashMap 循环遍历map的方法
- ⑧循环遍历Map、List的方法,哪个更快?
- java HashMap 循环遍历map的方法(转)
- java HashMap 循环遍历map的方法(转)
- HashMap的遍历方法
- 遍历HashMap的方法
- 遍历HashMap的方法
- hashmap的遍历方法
- HashMap的遍历方法
- 较快的排序
- 效率较高的map遍历方法
- HashMap最优的循环遍历方式
- HashMap的循环遍历推荐方式
- HashMap的四种循环遍历方式
- Java中HashMap的循环遍历方式
- MFC 取得启动参数 较快的方法
- Java的HashMap遍历方法
- PyQt4 学习笔记6之控件
- 连接Linux云服务器上的mysql服务器1.
- FAQ 前端面试题大杂烩
- iOS学习--webView笔记
- iOS获取启动页图片自己编辑动画
- 循环遍历HashMap的较快方法
- 黑马程序员---语句小结
- 互联网金融-众筹网站收集(转)
- 第 9 章 子窗口控件
- QT 中QMessageBox的用法
- oracle查询锁表解锁语句
- TextView加下划线的3种方式
- 关于解决Installation failed due to invalid APK file! Please check logcat output for more details.Launch
- 设计模式 一一一 简单工厂模式(静态工厂方法模式)