public class FailScores extends Exception {
public FailScores(){
super (“不及格的异常”);
}
public void printStackTrace(){
super.printStackTrace();
System.out.println(“成绩不是那么理想”);
}
public class Student {
int score;
public int getScore() {
return score;
}
public void setScore(int score) throws FailScores {
if(score<60){
throw new FailScores();
}
this.score = score;
}
public class Test {
public static void main(String[] args) {
Student zhangsan=new Student();
System.out.println(“程序开始运行”);
try {
zhangsan.setScore(59);
} catch (FailScores e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("程序运行完成");
}