java新手提问
请大神帮忙看看,那里有问题,我是要for输出这个数组的所有成员,编译通过了,但是java.exe执行时显示"Exceptioninthread"main"java.lan...
请大神帮忙看看,那里有问题,我是要for输出这个数组的所有成员,编译通过了,但是java.exe执行时显示"Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 97
at Test.main(Test.java:5)"
代码如下:
public class Test{
public static void main(String[] args){
char str[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
for(int x:str){
System.out.println(str[x]);
}
}
} 展开
at Test.main(Test.java:5)"
代码如下:
public class Test{
public static void main(String[] args){
char str[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
for(int x:str){
System.out.println(str[x]);
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询