fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5.  
  6. class Ideone
  7. {
  8. public static Function[] tb=new Function[]
  9. {
  10. new Function("abc")
  11. {
  12. @Override protected void run(Object o)
  13. {
  14. System.out.println("1");
  15. }
  16. },
  17. new Function("def")
  18. {
  19. @Override protected void run(Object o)
  20. {
  21. System.out.println("2");
  22. }
  23. },
  24. new Function("ghi")
  25. {
  26. @Override protected void run(Object o)
  27. {
  28. System.out.println("3");
  29. }
  30. }
  31. };
  32.  
  33. public static void main (String[] args) throws java.lang.Exception
  34. {
  35. String serverLine="x def y";
  36. for(Function i:tb) if(i.test(serverLine,null)) break;
  37. }
  38. }
  39.  
  40. class Function
  41. {
  42. private String text;
  43. protected void run(Object o) {}
  44. public boolean test(String line,Object o)
  45. {
  46. if(!line.contains(text)) return false;
  47. run(o);
  48. return true;
  49. }
  50. Function(String text) { this.text=text; }
  51. }
  52.  
Success #stdin #stdout 0.12s 320576KB
stdin
Standard input is empty
stdout
2