public class UserException
extends Exception
{
private String name;
UserException()
{
super();
} UserException(String name)
{
super(name);
this.name = name;
} public String toString()
{
return name + super.toString();
}}
extends Exception
{
private String name;
UserException()
{
super();
} UserException(String name)
{
super(name);
this.name = name;
} public String toString()
{
return name + super.toString();
}}
解决方案 »
- JAVA中有没有比这更好的处理int数组的方法
- 在eclipse下怎么导入项目源代码?
- 关于正则表达式抓取网页链接
- 一个有关数据库查询的出错信息,请高手释疑。
- >>>jni问题,用javah编译好.h文件后,怎么用VC做DLL文件<<<
- JAVA中继承的问题???
- 什么是jar啊?
- 打印嵌有applet的网页,Canon的BJC-4200没有问题,而用HP的黑白激光打印机打印,applet部分是一片黑??各位热心人请帮帮我,谢谢
- 那里可以下载Visualage for java 3.02
- Timer的schedule和scheduleAtFixedRate问题
- this用法不理解
- 开个高级JAVA栏把,这样初级,看好多初级的问题受不了啊
{
public TestUserException()
{
}
public static void main(String[] args)
{
int a=10,b=-10;
try
{
if (a>b)
throw new UserException("a is bigger than b!");
}
catch(UserException ue)
{
ue.printStackTrace();
}
}
}
...........
}catch( Exception e ){
throw new UserException();
}
try{
}catch(Exception e){
throw new UserException();
}
}
如果需要向上一级抛出异常,就需要在方法名用throws来定义要向调用者抛出的异常才行