O primeiro protótipo de Closures (recurso da linguagem que talvez seja incluído no Java 6 ou 7) está disponível.
Veja o post do sr. Neal Gafter em: http://gafter.blogspot.com/2007/10/java-closures-first-prototype.html
Um exemplo de programa com Closures:
import java.security.*;
interface StringIntDouble {
double invoke (String s, int x);
}
class TesteClosures {
/** Exemplo de closures - "closure literal" */
public void test1() {
// Sintaxe de closures
{String,String=>String} fn =
{String x, String y => x + "," + y};
System.out.println (fn.invoke ("ab", "c"));
// (Deve imprimir: "ab,c"
}
/** Exemplo de várias exceções tratadas com um único catch */
public void test2() {
MessageDigest md;
try {
md = MessageDigest.getInstance ("MD2", "SunJCE");
} catch (NoSuchAlgorithmException | NoSuchProviderException ex) {
ex.printStackTrace();
} finally {
System.out.println ("test2");
}
}
/** Exemplo de "closure conversion" */
public void test3() {
StringIntDouble obj2 = {String s, int x => (double) 42.0};
StringIntDouble[] obj3 = {
{String s, int x => (double) 1.0},
{String s, int x => (double) 2.0}
};
// Note que não se pode fazer isto:
// porque gera o erro "generic array creation".
// {String,int=>double} [] obj4 = {
// {String s, int x => (double) 1.0},
// {String s, int x => (double) 2.0}
// };
System.out.println (obj2.invoke ("abc", 4));
System.out.println (obj3[0].invoke ("abc", 6));
}
public static void main(String[] args) {
TesteClosures tc = new TesteClosures();
tc.test1();
tc.test2();
tc.test3();
}
}

hehehe