Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #23527
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.mixmin.net!eweka.nl!hq-usenetpeers.eweka.nl!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail |
|---|---|
| NNTP-Posting-Date | Sat, 20 Apr 2013 11:02:39 -0500 |
| Date | Sat, 20 Apr 2013 17:02:39 +0100 |
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
| Organization | Trollbusters 3 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: A small exercise |
| References | <exercise-20130420150736@ram.dialup.fu-berlin.de> |
| In-Reply-To | <exercise-20130420150736@ram.dialup.fu-berlin.de> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Message-ID | <R_2dnU9jtOi9Ie_MnZ2dnUVZ7q-dnZ2d@bt.com> (permalink) |
| Lines | 32 |
| X-Usenet-Provider | http://www.giganews.com |
| X-AuthenticatedUsername | NoAuthUser |
| X-Trace | sv3-2TamHtwwEmyib57/Oh+mNYmSNPHNDLk+UIv3lGwvioNUa+mBDNQ8bUVTulRvParVJ723v4ta5dnAinO!GhCxNtxtZig7wi1+HaYzb00mQ6Fb8whb6JcYEziBDUhGAfNzdMTpr0ewIknZYO2/eE3sjkJSPuw= |
| X-Complaints-To | abuse@btinternet.com |
| X-DMCA-Complaints-To | abuse@btinternet.com |
| X-Abuse-and-DMCA-Info | Please be sure to forward a copy of ALL headers |
| X-Abuse-and-DMCA-Info | Otherwise we will be unable to process your complaint properly |
| X-Postfilter | 1.3.40 |
| X-Original-Bytes | 2233 |
| Xref | csiph.com comp.lang.java.programmer:23527 |
Show key headers only | View raw
On 20/04/13 14:11, Stefan Ram wrote:
> Try to predict the behavior of the execution or compilation
> of the following code!
>
> public class Main
> { final int a; final int b;
> Main(){ this.a = 0; Main.this.b = 0; }
> public static void Main( final java.lang.String[] args )
> { new Main(); }}
>
> (I made this observation while programming something else
> using Oracle JDK 7, but I have not read the JLS about it yet.)
open-jdk6 and open-jdk7
I think that logically, Main.this.b refers to the enclosing *instance*
which implies that the class has been instantiated, final fields can
only be initialized once in a constructor so trying to (logically)
assign a value to a final variable after instantiation is illegal.
I think :-|
If you remove the final modifier from b then the code compiles, but then
you know this already.
lipska
--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
Back to comp.lang.java.programmer | Previous | Next — 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