Why do we need to use the latest version of the programming language

123 阅读1分钟

If you are still using jdk6, python2 in your project, I suggest you give up quickly.

Because many serious errors at the beginning of the design are being improved by good programmers, don't be affected by the wrong design.

For example: use try-with-resources is right, try-finally is evil.

In the past, a try-finally statement is a good way to ensure that resources are properly closed, even if the program throws an exception or returns.

This may not look bad, but when you add a second resource, the situation gets worse:

God bless you can understand.

^&^

    static String firstLineOfFile(String path) throws IOException {
        try (BufferedReader br = new BufferedReader(
                new FileReader(path))) {
            return br.readLine();
        }
    }