(String args[])
| 10 | |
| 11 | public class hash2 { |
| 12 | public static void main(String args[]) { |
| 13 | int n = Integer.parseInt(args[0]); |
| 14 | HashMap hash1 = new HashMap(10000); |
| 15 | HashMap hash2 = new HashMap(n); |
| 16 | |
| 17 | for(int i = 0; i < 10000; i++) |
| 18 | hash1.put("foo_" + Integer.toString(i, 10), new Val(i)); |
| 19 | for(int i = 0; i < n; i++) { |
| 20 | Iterator it = hash1.entrySet().iterator(); |
| 21 | while(it.hasNext()) { |
| 22 | Map.Entry h1 = (Map.Entry)it.next(); |
| 23 | String key = (String)h1.getKey(); |
| 24 | int v1 = ((Val)h1.getValue()).val; |
| 25 | if (hash2.containsKey(key)) |
| 26 | ((Val)hash2.get(key)).val += v1; |
| 27 | else |
| 28 | hash2.put(key, new Val(v1)); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | System.out.print(((Val)hash1.get("foo_1")).val + " " + |
| 33 | ((Val)hash1.get("foo_9999")).val + " " + |
| 34 | ((Val)hash2.get("foo_1")).val + " " + |
| 35 | ((Val)hash2.get("foo_9999")).val + "\n"); |
| 36 | } |
| 37 | } |
nothing calls this directly
no test coverage detected