fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. String first = "/Some object that has a loop in it object/";
  9. String second = "object";
  10. int ind = 0;
  11. int cnt = 0;
  12. while (true) {
  13. int pos = first.indexOf(second, ind);
  14. if (pos < 0) break;
  15. cnt++;
  16. ind = pos + 1;
  17. }
  18. System.out.println(cnt);
  19. }
  20. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
2