Test.java
public class Test {
 public static void main(String args[])
 {
  String str1="aacdabcd";
  String str2="abcdabcd";
  System.out.println(str1.indexOf(98));
  System.out.println(str2.index0f(98));
 }}

解决方案 »

  1.   

    编译错误?str1.indexOf(98)参数不能是数字,应该是str1.indexOf("ab") 还差不多
      

  2.   

    The method index0f(int) is undefined for the type String方法调错了吧,你上下两个indexOf()调的不一样,str2.indexOf(98),你第二个写成0(零)了吧
      

  3.   

    String.index0f(),的参数类型有两种一种是int,另外一种是String
    String.index0f(String str)而给它传递了一个int类型的参数因此报错。
      

  4.   

    public int indexOf(int ch)返回指定字符在此字符串中第一次出现处的索引。如果在此 String 对象表示的字符序列中出现值为 ch 的字符,则返回第一次出现该字符的索引(以 Unicode 代码单元表示)。