对于Java来说直接秒呗: public static int strStr(String haystack, String needle) { return haystack.indexOf(needle); }