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. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Set<String> set2 = new HashSet();
  13. set2.add("1;2");
  14. Set<String> set1 = new HashSet();
  15. set1.add("1");
  16. set1.add("2");
  17. set1.add("3");
  18. set1.forEach( k -> {
  19. for (String s : set2) {
  20. if(s.split(";")[0].equals(k)){
  21. //do something
  22. System.out.println(k);
  23. }
  24. }
  25. });
  26. }
  27. }
Success #stdin #stdout 0.08s 711168KB
stdin
Standard input is empty
stdout
1