public class Ren{
public static int check(String strage)throws MyException{
int age=Integer.parselnt(strage);
if(age<0){
throw new MyException("年龄不能为负数!");
}
return age;
}
public static void main(String[] args){
try {
int myage=check("-101");
System.out.println(myage);
} catch (NumberFormatException e) {
System.out.println("数据格式错误");
System.out.println("原因:"+e.getMessage());
}
catch(MyException e){
System.out.println("数据逻辑错误");
System.out.println("原因:"+e.getMessage());
}
}
}

public static int check(String strage)throws MyException{
int age=Integer.parselnt(strage);
if(age<0){
throw new MyException("年龄不能为负数!");
}
return age;
}
public static void main(String[] args){
try {
int myage=check("-101");
System.out.println(myage);
} catch (NumberFormatException e) {
System.out.println("数据格式错误");
System.out.println("原因:"+e.getMessage());
}
catch(MyException e){
System.out.println("数据逻辑错误");
System.out.println("原因:"+e.getMessage());
}
}
}

