fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6.  
  7. public static void checkAvailability() {
  8. String st = "Hello world!";
  9. String substr = "llo";
  10. for(int i=0;i<st.length()-substr.length();i++) {
  11. boolean mismatch = false;
  12. for(int j=0;j<substr.length();j++) {
  13. if( st.charAt(i+j)!=substr.charAt(j)) {
  14. mismatch = true;
  15. break;
  16. }
  17. }
  18. if (!mismatch) {
  19. System.out.println(i);
  20. break;
  21. }
  22. }
  23. }
  24. public static void main (String[] args) throws java.lang.Exception
  25. {
  26. checkAvailability();
  27. }
  28. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
2