|
Fred's right. As I understand it, the optimization is basically being able to make the calls inline. Java uses dynamic lookup for all method calls (very flexible but somewhat slow). Final methods don't require dynamic lookup because there can be no overriding methods. This is basically the opposite of C++ which uses static method lookup unless you use the virtual keyword. Another reason for the final keyword should become more obvious if you look at a more complex development scenario. If you are writing the object heirarchy yourself, you migh very well want to be able to extend anything anywhere. However, if *I* write the object hierarchy that you build on top of, I might not want you to be able to change the way certain things work for various reasons (security, object integrity, etc). Regards, Richard D. Dettinger AS/400 Java Data Access Team "TRUE! nervous, very, very dreadfully nervous I had been and am; but why WILL you say that I am mad? The disease had sharpened my senses, not destroyed, not dulled them. " - Edgar Allan Poe "The Tell-Tale Heart" Fred Kulack/Rochester/IBM@IBMUS@midrange.com on 11/06/2000 09:35:15 AM Please respond to JAVA400-L@midrange.com Sent by: owner-java400-l@midrange.com To: JAVA400-L@midrange.com cc: Subject: Re: Newbie question - Final classes > Would you really want a programmer to sub-class this class ? probably not ! Uh... Its perfectly reasonable to _WANT_ to sub-class string. HOWEVER.... My understanding of final is... Using final classes is really related to optimizations. Similar to final objects, the JVM, various JITs can do some good optimizations if they know for sure that an instance of String is really ONLY a string, and not some derived class. I.e. toString() always calls String.toString() and NEVER StringSubClass.toString(). Strings are primitive enough types and used frequently enough that these optimizations are probably important. "Do you believe that my being stronger or faster has anything to do with my muscles in this place?" ... "Free your mind." Laurence Fishburne as Morpheus in 'The Matrix'. Fred A. Kulack - AS/400e Java and Java DB2 access, Jdbc, JTA, etc... IBM in Rochester, MN (Phone: 507.253.5982 T/L 553-5982) mailto:kulack@us.ibm.com Personal: mailto:kulack@bresnanlink.net AOL Instant Messenger: Home:FKulack Work:FKulackWrk +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +--- +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.