title: 2nd System.out.println() statement not executing inside twoOccurences class
body: <pre><code>public class Part3 {
  public  static boolean twoOccurences(String stringa,String stringb){
      String a=stringa;
      String b=stringb;
      int index=0,count=0;
      System.out.println(index);
      if(b.indexOf(a)!=-1){
          return false;
      }else{
          System.out.println(index);
          while(index!=-1){
          index=b.indexOf(a,index);
          if(index!=-1){
              count++;
              index=index+a.length();
          }
      }
      }
      System.out.println(count&gt;=2);
      if(count&gt;=2)
          return true;
      else
          return false;
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public static void main(String args[]){
      System.out.println(twoOccurences("by", "A story by Abby Long"));
      System.out.println(twoOccurences("a", "banana"));
      System.out.println(twoOccurences("atg", "ctgtatgta"));
  }
  </code></pre>
  
  <p>I am trying to find the occurrence of the first string in the second. For the three method calls in main, I am getting the following output:</p>
  
  <pre><code>0
  false
  0
  false
  0
  false
  </code></pre>
  
  <p>The second System.out.println() statement isn't executing.Can someone explain the reason?    </p>