title: Searching an String array for a sub-string?
body: <p>I am trying to write a little method in java, but I cannot figure it out. What I want to be able to do is enter a string, and then the value of an int variable is set to the index of this in the array, i.e if I have an array consisting of</p>
  
  <pre><code>[0] 'hi guys'
  [1] 'this'
  [2] 'is'
  [3] 'sparta'
  </code></pre>
  
  <p>The value of my integer is set at 0, and I want to find the first occurrence of "ta", which will be [3], so I want the function to set my integer to 3.</p>
  
  <p>What I have at the moment is completely off the wall and wrong, is there any simple way of doing this ? I already have a function called get() defined which returns the value of the current line (i.e get(0) in this case would return 'hi guys'). Can anyone help me out please ?</p>
  
  <p>Thanks a lot :)</p>
  
  <pre><code> public void find(String line ) {
     boolean found = false;
     int i = cursor + 1;
     while ( found = false &amp;&amp; i!=cursor) {
     if ((doc.get(cursor).indexOf( line ) &gt; 0)){
    cursor = i;
    found = true;
     }else {
      cursor++;
      cursor%=doc.size();
      i++;
  
     }
   }
   }
  </code></pre>