fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.regex.*;
  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. String dictionary_str =
  13. "AL" + "\n"
  14. +"BAL" + "\n"
  15. +"BAK" + "\n"
  16. +"LABAT" + "\n"
  17. +"TAL" + "\n"
  18. +"LAT" + "\n"
  19. +"BALAT" + "\n"
  20. +"LA" + "\n"
  21. +"AB" + "\n"
  22. +"LATAB" + "\n"
  23. +"TAB" + "\n";
  24. String[] dictionary = dictionary_str.split("\n");
  25. for (int i=0; i<dictionary.length; i++)
  26. {
  27. if(dictionary[i].indexOf("B") > -1 &&
  28. dictionary[i].indexOf("T") > -1 &&
  29. dictionary[i].indexOf("L") > -1)
  30. {
  31. System.out.println("Match: " + dictionary[i]);
  32. }
  33. }
  34.  
  35. }
  36. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
Match: LABAT
Match: BALAT
Match: LATAB