Message-ID: <720833037.2545.1418962182918.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_2544_2094628444.1418962182918" ------=_Part_2544_2094628444.1418962182918 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