package com.niuke_1; class NoThisSoundException extends Exception{ public NoThisSoundException(){ super(); } public NoThisSoundException(String x){ super(x); } } class Player{ public void player(int index) throws NoThisSoundException{ if (index>10){ NoThisSoundException no = new NoThisSoundException("您播放的歌曲不存在"); throw no; } } } public class demo_5 { public static void main(String[] args){ Player pl = new Player(); try{ pl.player(21); }catch (NoThisSoundException no){ System.out.println(no.getMessage()); } } }
点赞 评论

相关推荐

点赞 评论 收藏
分享
09-14 20:51
四川大学 Java
慢热的鲸鱼在学习:985加粗就行了,第二个项目来不及准备也没事,省的写了问你你还不会。你只需准备面试八股和项目场景,剩下的交给985。即使面不过也没事,面试经验是最重要的,你现在不缺时间
简历中的项目经历要怎么写
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务