如何抛出ArrayIndexOutOfBoundsException?

joc*_*pa3 2 java arrays throw indexoutofboundsexception

我有一个检查2D数组中的斑点的方法,它还检查它们是否为空.我想扔掉ArrayIndexOutOfBoundsException因为我已经检查了null.

throws ArrayIndexOutOfBoundsException在声明方法后尝试添加,但它不起作用.我该怎么做呢?

tsk*_*zzy 8

throws在方法定义中说该方法可以抛出该异常.要将它实际抛入方法体中,请使用throw new ArrayIndexOutOfBoundsException();