class Getnum
{
public static void main(String[] args)
{
String str = "abkkcdkkdfkkskk";
sop(str);
sop(getnum(str,"kk"));
}
public static void sop(String str)
{
System.out.println(str);
} public static int getnum(String str,String key)
{
int num = 0;
int index = 0;
while((index=str.indexOf(key))!=-1)
{
str=str.substring(index+key.length());
num++;
}
return num;
}
}
看的毕老师的视频跟着做的,哪里出错了,编译一直出错:不兼容类型
感觉和视频代码一模一样啊,怎么错了啊
|