Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclass final class (Boolean) ?



Actually, the reason is immutability. If Boolean weren't final, you could do modify it as a parameter, so for example:

Boolean b = new Boolean(true);
someMethod.futzAbout(b);

//b can now be true or false

This is undesirable, especially as Boolean and friends are wrappers for their primitive versions, which due to pass by value are also 'immutable' in the same way.

On Aug 27, 2006, at 11:02 AM, Cameron Hayne wrote:

On 27-Aug-06, at 10:28 AM, Ken Anderson wrote:

OK, I'm a little annoyed here because I find the whole concept of 'final' to be ridiculous.

The idea is that other (existing) code can rely on the behaviour of the 'final'ized class. E.g. since Boolean is final, other code can rely on the fact that trueObj.toString() is "true", for example.


--
Cameron Hayne
email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Subclass final class (Boolean) ? (From: Ken Anderson <email@hidden>)
 >Re: Subclass final class (Boolean) ? (From: Cameron Hayne <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.