classSolution{ /* return a index to first occurence of target in source, or -1 if not exist */ publicintstrStr(String s1, String s2){ if(s1==null || s2==null) return -1; int j; for(int i=0; i<s1.length()-s2.length()+1;i++) { for(j=0; j<s2.length();j++) if(s1.charAt(i+j)!=s2.charAt(j)) break; if(j==s2.length()) return i; } return -1; } }