我知道这是不好的做法,虽然我知道我无法解释原因.
int [] intArr = ...
...
try{
int i = 0;
while(true){
System.out.println(intArr[i++]);
}
}catch(ArrayIndexOutOfBoundsException e){}
Run Code Online (Sandbox Code Playgroud)
我认为你只应该对不应该发生的事情使用例外.我问这个问题是因为我认为我有时会使用异常错误.如果你的编程运行一个标准的情况应该抛出异常?
这似乎是相关的: 防止异常与捕获Java中的异常
我想在Spring引导中自动为每个响应返回响应对象时返回404.
我需要建议.
我不想在控制器中检查它是否为null.