错误原因球援助!!!
Test.javapublic 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));
}
}
--------------------编程问答-------------------- 编译错误?
str1.indexOf(98)
参数不能是数字,应该是str1.indexOf("ab") 还差不多。。。 --------------------编程问答-------------------- The method index0f(int) is undefined for the type String
方法调错了吧,你上下两个indexOf()调的不一样,str2.indexOf(98),你第二个写成0(零)了吧 --------------------编程问答-------------------- String.index0f(),的参数类型有两种一种是int,另外一种是String
String.index0f(String str)而给它传递了一个int类型的参数因此报错。 --------------------编程问答-------------------- 谢谢··!! --------------------编程问答-------------------- 晕、把零当O用.... 汗 --------------------编程问答-------------------- 哈哈,楼主结贴吧 --------------------编程问答-------------------- public int indexOf(int ch)返回指定字符在此字符串中第一次出现处的索引。如果在此 String 对象表示的字符序列中出现值为 ch 的字符,则返回第一次出现该字符的索引(以 Unicode 代码单元表示)。
补充:Java , Java EE