package test;
import java.util.InputMismatchException;
import java.util.Scanner;
public class project1 {
public static void main(String []args) {
Scanner input =new Scanner(System.in);
boolean continueInput=true;
do {
try {
System.out.println("please input an integer");
int number=input.nextInt();
System.out.println("the number is "+number);
continueInput=false;
}catch(InputMismatchException e) {
System.out.println("try again(incorrect input:an integer is required");
input.nextLine();
}
}while(continueInput);
}
}
即使在到达finally块之前有一个return语句,finally语句还是会执行