Find that one string is substring of other or not
<pre><code>  public class StringIsSubstring {


public static void main(String[] args) {
    String s1= new String("anurag");
    String s2=new String("anu");

    char a[]=s1.toCharArray();
    char b[]=s2.toCharArray();
    int i=0;
    int j=0;

    while(i&lt;a.length &amp;&amp; j&lt;b.length)
    {
        if(a[i]==b[j])
        {
            i++;
            j++;
        }
        else
        {
            i++;
            j=0;
        }
        if(j == b.length)
        {
            System.out.println("we have found the substring");
        }
    }
}
 }
</code></pre>

<p>I have written following code to find that one String is substring of other or not. I dont want to use any library function. Is there any more efficient way to do the same</p>
