按照老毕写了一个类:public class StringTest {
public static void main(String[] args)
{
String4();
}
private static void Show(Object obj)
{
System.out.println(obj);
}
private static void String4()
{
String arr="dafl,kjla,kdj";
Show(arr.replace("da","ad"));
String[] str=arr.split(",");
for(int a=0;a<arr.length();a++)
{
Show(str[a]);
}
}
}
编译能同但是为什么运行时报错数组下标越界呢?adfl,kjla,kdjdafl
kjla
kdj
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at StringTest.String4(StringTest.java:60)
at StringTest.main(StringTest.java:8)
|