Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #30573
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Robert Klemme <shortcutter@googlemail.com> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: closures |
| Date | Tue, 16 Dec 2014 13:08:11 +0100 |
| Lines | 40 |
| Message-ID | <cfalldFc5ksU1@mid.individual.net> (permalink) |
| References | <closures-20141212234123@ram.dialup.fu-berlin.de> <16bs8alknk9spc3tb69k0qt5ivgh3n6rli@4ax.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net VB6ASHLpQS4+u3NZNN+OhwMYBLF4DdJDf2XuG/OasQWnlC2fE= |
| Cancel-Lock | sha1:FBVhDGxRWerSjipVFuwz44COeSs= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 |
| In-Reply-To | <16bs8alknk9spc3tb69k0qt5ivgh3n6rli@4ax.com> |
| Xref | csiph.com comp.lang.java.programmer:30573 |
Show key headers only | View raw
On 15.12.2014 01:37, Roedy Green wrote:
> On 12 Dec 2014 22:51:33 GMT, ram@zedat.fu-berlin.de (Stefan Ram)
> wrote, quoted or indirectly quoted someone who said :
>
>> Today, I wanted to show to the students that inner classes cannot
>> modify fields of outer classes
>
> You may be thinking about methods of an anonymous class can only
> reference final local variables of the enclosing method.
And, Stefan, note that "this" is final in the method, but members of
"this" are not, of course. Much the same way as in this example:
public final class Demo {
public int counter;
public static void main(String[] args) {
final Demo d = new Demo();
System.out.println(d.counter); // prints 0
new Runnable() {
@Override
public void run() {
++d.counter;
}
}.run();
System.out.println(d.counter); // prints 1
}
}
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: closures Roedy Green <see_website@mindprod.com.invalid> - 2014-12-14 16:37 -0800 Re: closures Robert Klemme <shortcutter@googlemail.com> - 2014-12-16 13:08 +0100
csiph-web