写出以下程序的运行结果。 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(9 ); mySqrt(-9 ); } catch( MyException e ){ System.out.println("Caught "+e); } } } 运行结果是:______。
发布时间:2024-05-21 21:24:49