> For the complete documentation index, see [llms.txt](https://ucan.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ucan.gitbook.io/notes/28.-implement-strstr.md).

# 28. Implement strStr()

```java
class Solution {
    public int strStr(String haystack, String needle) {
        for(int i =0; ; i++){
            for(int j=0; ; j++){
                if (j == needle.length()) return i;
                if (i+j==haystack.length()) return -1;
                if (needle.charAt(j)!=haystack.charAt(i+j)) break;
            }
        }
    }
}
```
