Small Changes for Java JDK7

bearophile bearophileHUGS at lycos.com
Sun Mar 1 16:02:35 PST 2009


From:
http://jeremymanson.blogspot.com/2009/02/small-language-changes-for-jdk7.html

Automated Resource Blocks, to be able to say things like:

try (BufferedReader br = new BufferedReader(new FileReader(path)) {
  return br.readLine();
}

instead of:

BufferedReader br = new BufferedReader(new FileReader(path));
try {
   return br.readLine();
} finally {
   br.close();
}

based on having BufferedReader implement a Disposable interface.

------------------

Exception handling improvements:

try {
    doWork(file);
} catch (final IOException | SQLException ex) {
    logger.log(ex);
    throw ex;
}

Bye,
bearophile



More information about the Digitalmars-d mailing list