没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
class IntegerException extends Exception
{ String message;
IntegerException(int m)
{ message="年龄"+m+"不合理";
}
public String toString()
{ return message;
}
}
class People
{ private int age=1;
public void setAge(int age) throws IntegerException
{
if(age>=160||age<=0)
throw new IntegerException(age);
else
this.age=age;
}
public int getAge()
{ System.out.println("年龄"+age+"合理");
return age;
}
}
public class cz1
{ public static void main(String args[])
{ People wang=new People(),
zhang=new People();
try { wang.setAge(189);
System.out.println(wang.getAge());
}
{ String message;
IntegerException(int m)
{ message="年龄"+m+"不合理";
}
public String toString()
{ return message;
}
}
class People
{ private int age=1;
public void setAge(int age) throws IntegerException
{
if(age>=160||age<=0)
throw new IntegerException(age);
else
this.age=age;
}
public int getAge()
{ System.out.println("年龄"+age+"合理");
return age;
}
}
public class cz1
{ public static void main(String args[])
{ People wang=new People(),
zhang=new People();
try { wang.setAge(189);
System.out.println(wang.getAge());
}
资源评论
上善三生0-0
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功