dfa*_*dfa 402
java.lang.UnsupportedOperationException
抛出以指示不支持所请求的操作.
ste*_*fen 212
区分您命名的两个案例:
为了表明不支持所请求的操作,并且很可能永远不会支持,请抛出一个UnsupportedOperationException.
要指示所请求的操作尚未实现,请在以下选项之间进行选择:
使用commons-lang2中提供的NotImplementedExceptionfrom apache commons-lang,并在3.2版本中重新添加到commons-lang3.
实施自己的NotImplementedException.
抛出UnsupportedOperationException一条消息,例如"尚未实施".
Ben*_*uer 23
如果在NetBeans中创建新的(尚未实现的)函数,则它将使用以下语句生成方法体:
throw new java.lang.UnsupportedOperationException("Not supported yet.");
Run Code Online (Sandbox Code Playgroud)
因此,我建议使用UnsupportedOperationException.
下面的Calculator示例类显示了差异
public class Calculator() {
int add(int a , int b){
return a+b;
}
int dived(int a , int b){
if ( b == 0 ) {
throw new UnsupportedOperationException("I can not dived by zero,
not now not for the rest of my life!")
}else{
return a/b;
}
}
int multiple(int a , int b){
//NotImplementedException from apache or some custom excpetion
throw new NotImplementedException("Will be implement in release 3.5");
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
137040 次 |
| 最近记录: |