本帖最后由 南山忆 于 2015-5-21 22:13 编辑
- package three;
- public class Demo2 {
- public static void main(String[] args) {
-
- String string = "asdfghjkl";
-
- //将字符串变成字符数组
- char[] ch = string.toCharArray();
-
- //将字符数组进行反转
- for( int x=0,y=ch.length-1;x<y;x++,y--) {
-
- char temp = ch[x];
- ch[x] = ch[y];
- ch[y]= temp;
-
- }
-
- System.out.println(new String(ch));
-
- }
- }
复制代码
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 97
at three.Demo2.main(Demo2.java:17)
请问这个错在哪里了???? |
|