本帖最后由 HM何伟 于 2013-4-1 00:03 编辑
- /*
- 自定义异常实例:
- */
- import java.lang.Exception;
- class Throws
- {
- public static void main(String[] args)
- {
- try
- {
- int m=function(24,-3);
- System.out.println(m);
- }
- catch (FuShuException e)
- {
- //System.out.println(toStirng());
- // System.out.println("除数出现负数了");
-
- }
-
-
- int function(int a,int b)throws FuShuException
- { if(b<0)
- throw new FuShuException("出现负数了-----/by fushu");//
- return a/b;
- }
- }
- }
- class FuShuException extends Exception
- {
- FuShuException(String msg)
- {
-
- super(msg);
- }
- }
复制代码 请问这段代码有些什么问题? |