public class damo2 {
public static void sop(String str)
{
System.out.println(str);
}
public static void main(String[] args) {
String str="abjggsorggojopggoj[kgg";
sop(get(str,"gg")); //这里怎么 出错了
}
public static int get(String str ,String key)
{ int come=0;
int index=0;
while((index=str.indexOf(key,index))!=-1)
{
index=index+key.length();
come++;
}return come;
}
}
|
|