563

First-class methods: Java-style closures

Sorting exampleThe Comparator interface is the standard mechanism in Java to provide the code needed to sort lists. Here is a Comparator that sorts by length of String: List list = ... Collections.sort(list, new Comparator() { public int compare(String str1, String str2) { return str1.length() - str2.length(); } });With the changes in this proposal, the code could be written as follows: List list = ... Collections.sort(list, #(String str1, String str2) { return str1.length() - str2.length(); });mai mult aici:http://docs.google.com/View?docid=ddhp95vd_6hg3qhcps: totusi e bine ca au facut java open-source :)am uitat sa pun link de unde se poate downloada prototipul :)http://www.jroller.com/scolebourne/entry/fcm_prototype_availableinca niste docuri la tema :)http://www.javac.info/
0