title: Trying to find an array within another array in Java
body: <p>So I have an array t and an array x. I'm trying to find the pattern "abc" of the array t inside the array x, which is at index 5 of the array. I've written this code so far but am lost as to why this is not working...</p>
  
  <p>Also, I'm not allowed to use anything else but <em>while !=</em> or <em>while ==</em> in my code, making it a tad trickier. (Would've used a simple for loop otherwise).</p>
  
  <p>Any ideas?</p>
  
  <pre><code>public static void main(String[] args){
  
  
    char t[]={'a','b','c'};
    char x[]={'e','a','b','x','c','a','b','c'};
    int i=0, j=0, c=0;
    boolean a = false;
    while(i != x.length){
        if(t[0]!= x[i]){
            i++;
            continue;
        }
        else{
            j=0;
            while(j != t.length){
                if(t[j]==x[i+j])
                c++; j++;
            }
        if(c==t.length){
           a = true;
            break;
        }
        else{
            i=i+c-1;    
            c=0;
        }
    }
    if (a == true)
    System.out.println("index: "+i); 
    else
    System.out.println("Match not found");
  
    }
  }
  </code></pre>