Message-ID: <650986344.791172.1386643564150.JavaMail.firstname.lastname@example.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_791171_1980139529.1386643564150" ------=_Part_791171_1980139529.1386643564150 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
At one level they just allow internal iterators instead of external ones= . This alone is really nice because looping is a lot cleaner. With Iterator= s for example you do all the work, because if you want to execute the loop = of the body, you have to take responsibility for hasNext() and next().= =20
So its basically providing the body of a loop or a callback etc which
will execute within the original scope.
Anonymous classes can seem like they are in fact closures, but they have= limitations that cause annoying things like having to declare all your var= iables as final. The compiler just creates a synthetic constructor that tak= es any variables you are going to reference.=20
For me the main benefit of closures is that they allow you to write code= for collections with a lot less boilerplate.=20