was, but it's essentially the same code for when no */所以,我想保持我的异常除了分配给每个catch块中的变量之外,还有其他方法吗?
编辑:只是为了澄清,请不要发布答案,暗示我在try块外使用了一个限定范围的变量。我知道我能做到这一点,这个问题的重点是找到一个替代方案。现
由于不抛出try块中的异常的方法,对下面的代码会产生任何负面的性能影响吗?String user; user = SomeHelper.getUserName(); //Does not throw anything explicitly//This will throw exception e.printStackTrace();