title: count directly repeated substring occurence
body: <p>I am trying to count the number of directly repeatings of a substring in a string.</p>
  
  <pre><code>String s = "abcabcdabc";
  String t = "abc";
  int count = 2;
  </code></pre>
  
  <p>EDIT:
  because some people are asking, i try to clarify this: there are 3 times t in s but i need the number of times t is repeated without any other character. that would result in 2, because the d in my example is not the starting character of t. ('d' != 'a'). </p>
  
  <p>Another example to clarify this:</p>
  
  <pre><code>String s = "fooabcabcdabc";
  String t = "abc";
  int count = 0;
  </code></pre>
  
  <p>I know how to count the number of occurrences in the string, i need it to be repeating from left to right without interruption!</p>
  
  <p>Here is what i have so far, but i think i made a simple mistake in it...</p>
  
  <pre><code>public static int countRepeat(String s, String t){
      if(s.length() == 0 || t.length() == 0){
          return 0;
      }
      int count = 0;
      if(t.length() == 1){
          System.out.println(s+" | " + t);
          for (int i = 0; i &lt; s.length(); i++) {
              if (s.charAt(i) != t.charAt(0)){
                  return count;
              }
              count++;
          }
      }else{
          System.out.println(s+" | " + t);
          for (int i = 0; i &lt; s.length(); i++) {
              int tchar = (i- (count*(t.length()-1)));
              System.out.println(i+ " | " + tchar);
              if (s.charAt(i) != t.charAt(tchar)){
                  return count;
              }
              if(tchar &gt;= t.length()-1){
                  count++;
              }
          }
      }
      return count;
  }
  </code></pre>
  
  <p>what am i doing wrong? And is there a better/faster way to do this?</p>