Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.netfront.net!not-for-mail From: Wanja Gayk Newsgroups: comp.lang.java.programmer Subject: Re: Usefulness of "final" (Was: Re: Inserting In a List) Date: Sun, 7 Apr 2013 17:28:23 +0200 Organization: Netfront http://www.netfront.net/ Lines: 35 Message-ID: References: <19un43xj77bua.vw45l4e2wshi.dlg@40tude.net> <515cabb2$0$32111$14726298@news.sunsite.dk> <515cc192$0$32109$14726298@news.sunsite.dk> <515cc3b2$0$32111$14726298@news.sunsite.dk> <515cde06$0$32111$14726298@news.sunsite.dk> NNTP-Posting-Host: 93.130.29.211 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: adenine.netfront.net 1365348365 32481 93.130.29.211 (7 Apr 2013 15:26:05 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Sun, 7 Apr 2013 15:26:05 +0000 (UTC) User-Agent: MicroPlanet-Gravity/3.0.4 Xref: csiph.com comp.lang.java.programmer:23362 In article , markspace (markspace@nospam.nospam) says... > > "final" is not necessary to get a thread safe immutable object either, > > Well, according to Brian Goetz it is. Check the section on immutability > (page 47 I think) where he lists the three requirements of immutable > objects in Java. "Use final fields" (paraphrased) is the first one. > [..] > (I realize Brian Goetz takes that statement back in a footnote. Which he does because he knows what you know and what I know that this class... public class Foo{ private int value; private Foo(int value){this.value=value;} public static Foo createFoo(int value){return new Foo(value);} public int getValue(){return value;} } ..is both immutable, thread safe and can't be overridden either, without having a single "final" in it. This is where your whole argument falls apart. Kind regards, -Wanja- -- ..Alesi's problem was that the back of the car was jumping up and down dangerously - and I can assure you from having been teammate to Jean Alesi and knowing what kind of cars that he can pull up with, when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer] --- news://freenews.netfront.net/ - complaints: news@netfront.net ---