MyExceptionTest.java 478 B

1234567891011121314151617181920
  1. package com.sf.javase.day11.exception;
  2. public class MyExceptionTest {
  3. public void regist(int age) throws MyException {
  4. if(age<0){
  5. throw new MyException("age<0",1);
  6. }else System.out.println("====");
  7. }
  8. public void regist1(int age) throws MyException {
  9. try {
  10. int c = age;
  11. }catch (RuntimeException e){
  12. throw new MyException("age<0",2);
  13. // ArrayIndexOutOfBoundsException
  14. }
  15. }
  16. }