为什么会报错呢?错误cannot resolve symbol method indexof (java.lang.String)
publicclassli{publicintfunc(Stringstr1){Stringcontent=str1;Stringsubstr="hao";intt=co...
public class li
{
public int func (String str1)
{ String content=str1;
String substr="hao";
int t=content.indexof(substr);
return t;
}
public static void main(String [] args)
{
String str="nihaonihao";
li aa=new li();
int x=aa.func(str);
System.out.print(x);
}
} 展开
{
public int func (String str1)
{ String content=str1;
String substr="hao";
int t=content.indexof(substr);
return t;
}
public static void main(String [] args)
{
String str="nihaonihao";
li aa=new li();
int x=aa.func(str);
System.out.print(x);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询