package com.java1995;public class AgeText { public static void main(String[] args) { try { ageLeve(12); } catch (IllegaAgeException e) { // TODO Auto-generated catch block e.printStackTrace(); } } static String ageLeve(int age) throws IllegaAgeException{ if(age>=10&&age<=22){ return "少年 "; }else if(age<10){ return "儿童"; }else if(age>22&&age<120){ return "成年"; }else{ //抛出异常 throw new IllegaAgeException("非法的年龄!!!"); } }}class IllegaAgeException extends Exception{ public IllegaAgeException(String msg){ super(msg); }}我在main函数里输入的年龄是12,为什么虚拟机输出为空,不是应该是青年的吗?
添加回答
举报
0/150
提交
取消