daily pastebin goal
43%
SHARE
TWEET

Untitled

a guest Dec 14th, 2018 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Map<Integer, Integer> map = new HashMap<Integer,Integer>();
  2.  
  3. int[] sizeEight = {1,2,3,4,5,6,7,8};
  4. int[] sizeTen = {1,2,3,4,5,6,7,8,9,10};
  5.  
  6. for(int i = 0; i < sizeEight.length; i++) {
  7.     if(map.containsKey(sizeEight[i])) {
  8.         int count = map.get(sizeEight[i]);
  9.         map.put(sizeEight[i],(count + 1));
  10.     }
  11.     else {
  12.         map.put(sizeEight[i],1);
  13.     }
  14. }
  15.  
  16. for(int i = 0; i < sizeTen.length; i++) {
  17.     if(map.containsKey(sizeTen[i])) {
  18.         int count = map.get(sizeTen[i]);
  19.         map.put(sizeTen[i],(count + 1));
  20.     }
  21.     else {
  22.         map.put(sizeTen[i],1);
  23.     }
  24. }
  25.  
  26. System.out.println("The following numbers are unique:");
  27.  
  28. Iterator i = map.Iterator();
  29. while(i.hasNext()) {
  30.     Map.Entry me = (Map.Entry)i.next();
  31.    
  32.     if(me.getValue() == 1) {
  33.         System.out.println(me.getKey() + " ");
  34.     }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top