写出以下程序的运行结果:class MyException extends Exception{public String toString( ){ return "negative"; }}public class ExceptionDemo{public static void mySqrt(int a) throws MyException {if( a<0 ) throw new MyException();System.out.println(Math.sqrt(a));}public static void main( String args[] ){try{ mySqrt(25 ); mySqrt(-5 ); }catch( MyException e ){ System.out.println("Caught " e); }}}
发布时间:2024-04-16 09:59:50