公共类主要{如何摆脱ArrayIndexOutOfBound异常的错误?
public static void main(String[] args) {
int[] numbers = {1, 2, 3}; // it gives me arrayindexoutofboundexception
int length = numbers[3];
char[] chars = new char[length];
chars[numbers.length + 4] = 'y';
System.out.println("Done!");
}
}
如何删除数组索引出界异常。
非常感谢,它帮助。 如果我试图捕捉异常,那么它会毫无例外地编译,但没有输出,你能解释一下,谢谢? –
@KedarKholiya别抓住这个例外。你应该首先避免它。 – Eran