fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10.  
  11. public static void main(String[] args) {
  12. // TODO Auto-generated method stub
  13. Map<Integer, String> masterMap = new HashMap<Integer, String>();
  14. masterMap.put(1537, "OK");
  15. masterMap.put(1538, "OK");
  16. masterMap.put(4003, "OK");
  17.  
  18. Set<Integer> selectedSet = new HashSet<Integer>();
  19. selectedSet.add(Integer.parseInt("4003"));
  20. boolean compareMapAndSet = checkSubSet(masterMap.keySet(), selectedSet);
  21. System.out.println(compareMapAndSet);
  22. }
  23.  
  24. private static boolean checkSubSet(Set<Integer> keySet, Set<Integer> selectedSet) {
  25. for (Integer integer : selectedSet) {
  26. if (!keySet.contains(integer)) {
  27. return false;
  28. }
  29. }
  30. return true;
  31. }
  32. }
Success #stdin #stdout 0.09s 320576KB
stdin
Standard input is empty
stdout
true