我想知道如何为以下错误添加if语句:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at Calendar.main(Calendar.java:14)
换句话说,我想在触发以下错误时显示以下文字,"错误。请输入缺少的元素。"
答案 0 :(得分:0)
try{
//do something that causes that error
catch(ArrayIndexOutOfBoundsException e){
//error ocurred
}