package four;
import java.io.*;
public class TestThrowException extends Exception
{
public static void square(double n) throw TestThrowException
{
if(n<0.0)
throw new TestThrowException();
else
Math.sqrt(n);
}
public static void main(String[] args)throws IOException
{
double number = 0 ;
TestThrowException tt = new TestThrowException() ;
try
{
System.out.println("input double number");
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine() ;
number = Double.parseDouble(s);
tt.square(number);
}
catch( TestThrowException e1)
{
System.out.println(e1.toString()+"输入数据有误");
}
}
}
这段代码报错是TestThrowException不是throwable的
求修改
Caballarii
相关分类