1throw new java.lang.Error("this is very bad");
2throw new java.lang.RuntimeException("this is not quite as bad");
1public static void main(String[] args) {
2 Scanner kb = new Scanner(System.in);
3 System.out.println("Enter a number");
4 try {
5 double nb1 = kb.nextDouble();
6 if(nb1<0)
7 throw new ArithmeticException();
8 else System.out.println( "result : " + Math.sqrt(nb1) );
9 } catch (ArithmeticException e) {
10 System.out.println("You tried an impossible sqrt");
11 }
12}