Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!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: Thu, 04 Apr 2013 07:41:14 -0500 Date: Thu, 04 Apr 2013 13:41:11 +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: Usefulness of "final" (Was: Re: Inserting In a List) References: <19un43xj77bua.vw45l4e2wshi.dlg@40tude.net> <%Ya7t.205181$Nl5.140602@newsfe07.iad> <4_ydnVbj7JDV1MDMnZ2dnUVZ8h6dnZ2d@bt.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <8PSdnU6kk5l36cDMnZ2dnUVZ7r6dnZ2d@bt.com> Lines: 58 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-ZdtMxJ/ArRJJib/lTb5TZVIkh6SsO7PhIIpihdCe1owdUOueg1esm2RynclMKY/o1qAZmIjSOX+JtqC!DeGM1iFqmTDD3rR2KUU3Bo+Pc9C6fc/f1/RsDoc/dsdF3RuiN0Efc8/kJb3Q4UMFw910fDcoA9s= 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: 3858 Xref: csiph.com comp.lang.java.programmer:23297 On 04/04/13 13:02, Joerg Meier wrote: > On Thu, 04 Apr 2013 10:35:02 +0100, lipska the kat wrote: > >> On 04/04/13 09:37, Arved Sandstrom wrote: >>> On 04/04/2013 05:09 AM, lipska the kat wrote: >>>> On 03/04/13 20:01, Joerg Meier wrote: >>>>> On Wed, 03 Apr 2013 19:51:05 +0100, lipska the kat wrote: [snip] >> A variable that is final is no longer variable, it is not modifiable, on >> that I think we all agree. > > Correct. I disagreed with your statement (emphasis added by me): > > On Wed, 03 Apr 2013 19:51:05 +0100, lipska the kat wrote: >> [...] When I see the >> modifier final it says something to me, it says, this *value* is not >> modifiable ('scuse the pun). > > The variable/reference itself is not modifiable, but its VALUE certainly > is. Nooooo, I just Can't agree with this I'm afraid :-) The *value* of a reference variable is (an abstraction of) a memory address. That value cannot be changed if the final modifier is used at declaration time, The *value* at the address that the reference variable refers to may or may not be modifiable. > And that, I feel, is the problem with using final to mean "this will be > the same throughout the code": > > final Point p = new Point(0,0); > > You can not be sure that the value of p will stay 0,0 throughout the code. But this is not what I would assume at all. Looking at your example I see a variable p of type Point. The variable p has the final modifier applied which means that p will always point(:) to that instance of Point. p cannot be re-assigned, therefore the value of p is not modifiable. That's all it means, I have never assumed or suggested otherwise. what you do with the instance referred to by p is another matter entirely. I think it would be more correct to refer to the *value of Point p* as opposed to the value of p, p is not modifiable, Point p is. It's a question of terminology I suppose and the semantics of words like value in the context of Java variables. lipska -- Lipska the KatŠ: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun