package all_test; class NoThisSoundException extends Exception{     private static final long serialVersionUID = 1972549693000089438L;     public NoThisSoundException() {         super();     }          public NoThisSoundException(String msg) {         super(msg);     } } class Player{     static final int start=0;     static final int end=10;          public static void play(int index) throws NoThisSoundException{         if(index<start||index>end) {             throw new NoThisSoundException("你播放的歌曲不存在");         }         System.out.println("那一天,人们想起了被咸鱼支配的恐惧");     } } public class Test_5 {     public static void main(String[] args) {         try {             System.out.println("歌名:咸鱼突刺");             Player.play(5);             System.out.println("\n歌名:当咸鱼有了梦想");             Player.play(11);         }catch(NoThisSoundException e1) {             System.out.println(e1.getMessage());         }catch(Exception e2) {             System.out.println(e2.getStackTrace());         }finally {             System.out.println("\n咸鱼翻身也逃不出咸鱼的命运");         }         System.out.println("\n咸鱼挂了,完结撒花");     } }
点赞 评论

相关推荐

notbeentak...:真的nc,算毕业6月份,要给这种b公司打半年多白工😅
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务