这段代码抛出
错误“线程“main”中的异常 java.lang.ArrayIndexOutOfBoundsException:0
在 basic2.compareStrPractice.main(compareStrPractice.java:15)”
int i;
char[] chr1 = {};
char[] chr2 = {};
String s1 = "man";
String s2 = "nam";
for ( i= 0; i<s1.length(); i++){
chr1[i] = (char)s1.charAt(i);
chr2[i] = (char)s2.charAt(i);
}
if ((chr1[0] == chr2[2]) && (chr1[1] == chr2[1]) && (chr1[2] == chr2[0])){
System.out.println("They are Palindrom!");
}
}
我想打印声明。但它抛出 ArrayOutOfBoundary 错误。
米脂
qq_遁去的一_1
鸿蒙传说
相关分类