Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #23671
| From | markspace <markspace@nospam.nospam> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: A small exercise |
| Date | 2013-04-27 13:53 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <klhdn2$oim$1@dont-email.me> (permalink) |
| References | <exercise-20130420150736@ram.dialup.fu-berlin.de> <R_2dnU9jtOi9Ie_MnZ2dnUVZ7q-dnZ2d@bt.com> <au2n7aF1rgnU1@mid.dfncis.de> |
On 4/27/2013 12:28 PM, Sven Köhler wrote: > Am 20.04.2013 19:02, schrieb lipska the kat: >> I think that logically, Main.this.b refers to the enclosing *instance* >> which implies that the class has been instantiated > > "this" also refers to an instance - doesn't it? > And following your argument, I should not be able to use "this" in the > constructor. Right, in a ctor, "this" refers to the object under construction. Ctors are not static methods, they are instance methods that don't inherit or participate in dynamic method name resolution. The original question is kinda weird, Main.this.b feels like it should be a static reference of some sort, or a reference to an enclosing instance or something. It's a valid question, but also rather unnatural to write and a corner case of the language. I think the OP is asking for his class and students. I can't really give a good answer why it does what it does. "It no work" is about all I can say, and encourage the student to use "this.b" in cases like the one cited. > > I'm not saying, that the JLS makes a different between a mere "this" and > a construct of the form "Classname.this" and that this is essentially > the cause for the code not compiling. But I don't see the point of your > argument.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: A small exercise lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-20 17:02 +0100
Re: A small exercise Arne Vajhøj <arne@vajhoej.dk> - 2013-04-20 15:15 -0400
Re: A small exercise lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-21 11:04 +0100
Re: A small exercise Arne Vajhøj <arne@vajhoej.dk> - 2013-04-26 22:13 -0400
Re: A small exercise lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-27 09:25 +0100
Re: A small exercise Arne Vajhøj <arne@vajhoej.dk> - 2013-04-27 21:58 -0400
Re: A small exercise "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-04-28 11:34 +0100
Re: A small exercise Martin Gregorie <martin@address-in-sig.invalid> - 2013-04-28 12:17 +0000
Re: A small exercise lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-28 14:05 +0100
Re: A small exercise Sven Köhler <remove-sven.koehler@gmail.com> - 2013-04-28 16:14 +0300
Re: A small exercise lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-28 14:54 +0100
Re: A small exercise Arne Vajhøj <arne@vajhoej.dk> - 2013-04-28 09:57 -0400
Re: A small exercise Arne Vajhøj <arne@vajhoej.dk> - 2013-04-28 10:14 -0400
Re: A small exercise Sven Köhler <remove-sven.koehler@gmail.com> - 2013-04-27 22:28 +0300
Re: A small exercise markspace <markspace@nospam.nospam> - 2013-04-27 13:53 -0700
Re: A small exercise Arne Vajhøj <arne@vajhoej.dk> - 2013-04-27 21:44 -0400
Re: A small exercise lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-28 10:37 +0100
csiph-web