小编lan*_*x86的帖子

Checked Exception需要在编译时使用try,catch和finally关键字进行处理,否则编译器将标记错误

我对java的异常检查感到困惑

Checked Exception需要在编译时使用try,catch和finally关键字进行处理,否则编译器将标记错误

阅读更多:http://javarevisited.blogspot.com/2013/06/10-java-exception-and-error-interview-questions-answers-programming.html#ixzz3pk6OBSrj

我的问题是:我们都知道" NoSuchMethodExcepion "被检查异常,并且考虑上面的语句,这是否意味着每当我尝试调用一个方法时,我应该使用try,catch来包含调用这样的方法代码

try{
   callingMethod();
}
catch(Exception){
}
Run Code Online (Sandbox Code Playgroud)

但事实上,我不需要这样做吗?那么首先给出的陈述的真正含义是什么?谢谢你回答我的问题.

java exception

5
推荐指数
1
解决办法
184
查看次数

解释此代码的输出(当使用连续赋值并更改将在同一语句中使用的变量时)

public class Main{
    public static void main(String[] args){
        int a = 0;
        int[] b = new int[5];
        int c = 3;
        b[a] = a = 3;//a is covered with 3, why the entry assigned with 3 is b[0] instead of b[3]
        System.err.println(b[0]);
        System.err.println(b[3]);
        System.err.println(b[a]);
    }
}
Run Code Online (Sandbox Code Playgroud)

输出是:

3
0
0
Run Code Online (Sandbox Code Playgroud)

我想原因可能是第五个像中间变量缓冲区,但我仍然不太确定该语句是如何b[a] = a = 3;工作的.

java buffer

5
推荐指数
0
解决办法
58
查看次数

标签 统计

java ×2

buffer ×1

exception ×1