If there are so finally in return try not to have return or will not try to perform in return

public class TryExer {
    public static void main(String[] args) {
        String test = test();
        System.out.printf("返回:"+test);
    }

    public static String test(){
        try {
            System.out.println("try");
            return "try";
        } catch (Exception e) {
            System.out.println("catch");
            e.printStackTrace();
        }
        finally {
            System.out.println("finally");
            return "finally";
        }
    }
}

 

Guess you like

Origin www.cnblogs.com/honghong75042/p/11578874.html