throw new IndexOutOfBoundsException("your message goes here");
如果您需要打印该消息,请从捕获该异常的地方执行此操作. (您可以使用getMessage()方法来访问消息.)