?? student.java
字號:
class Student
{
String name;
int age;
Student(String name,int age) throws ageException
{
if(age>80||age<15)
throw new ageException(age);
this.name=name;
this.age=age;
}
public void putMessage()
{
System.out.println("name:"+name);
System.out.println("age:"+age);
}
public static void main(String[] args)
{
try
{
Student st=new Student("lili",20);
st.putMessage();
Student st1=new Student("pp",85);
st1.putMessage();
}
catch(ageException e)
{
System.out.println(e);
}
}
}
class ageException extends Exception
{
int age;
ageException(int age)
{
this.age=age;
}
public String toString()
{
return "The age must between 15-80:"+age;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -