两个类,关系如下
public class Parent {
public Parent() throws RemoteException {
System.out.println("in parent...");
}
}
public class Child extends Parent {
//error
//Default constructor cannot handle exception type RemoteException thrown by implicit super
//constructor. Must define an explicit constructor
}为什么当parent的构造器抛出RemoteException的时候,Child会编译错误?如果Parent的构造器抛出的是NullpointException,为什么上述代码又是没有问题的呢?
public class Parent {
public Parent() throws RemoteException {
System.out.println("in parent...");
}
}
public class Child extends Parent {
//error
//Default constructor cannot handle exception type RemoteException thrown by implicit super
//constructor. Must define an explicit constructor
}为什么当parent的构造器抛出RemoteException的时候,Child会编译错误?如果Parent的构造器抛出的是NullpointException,为什么上述代码又是没有问题的呢?
解决方案 »
- java swing 控件这么少,要用其他控件,不是要自己写吧?
- 生兔子问题求第三解
- 1200=107.2×{[1-(1+r)^(-12)]/r}如何用java代码实现
- 一个关于args的代码,看不懂
- Java 库中有没有可用的Tree类?(纯数据的),最好有深度优先的遍历方法?
- 高手请进:关于派生类与集合的问题
- 一道题难住了很多人,看看你是不是一个!
- 关于数组输出的区别问题???
- Serializable接口拿来干什么用的?举个简单例子看看?
- 大家觉得,说'Thread在同一份资源不共享'的观点是不是错的?
- 有一个例子生动说明多线,坛友提供,但我不知道什么意思?
- 紧急询问,关于JscrollBar中滑块和箭头按钮的更改
这里估计RemoteException需要捕获吧.
NullPointerException就如1楼所说的,它是继承自RuntimeException,运行时异常不必显式的捕获.