Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-02-2008, 11:18 AM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 263
roots is on a distinguished road
What kinds of classes needs to be final.
Why should a class be a final class? can some one please give real life example where a class needs to be final to serve it's purpose in object oriented design.
Thank you.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-02-2008, 07:00 PM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
Hello, roots.

I think you add the final modifier when you completed a class and you know that there will be no need for it to be the super class of some other class. For example: Let's say Planet is a subclass of Body and Earth is a subclass of Planet, but you do not get different types if Earths as you get different types of planets. Thus, the Earth class must be declared final. I think the purpose of this is to improve performance.

Hope this helps.
__________________
If your ship has not come in yet then build a lighthouse.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-02-2008, 07:09 PM
Senior Member
 
Join Date: Jun 2007
Location: Bali, ID
Posts: 102
wsaryada is on a distinguished road
Or if you want to create a class that no one can extends due to the critical functionality in the class. A String class is an example of final class in the Java API.
__________________
Website:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- Blog:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-03-2008, 02:54 PM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 263
roots is on a distinguished road
I had a long standing doubt on final classes. May be more people can talk about their views on using final classes for themselves. Thank you tim again "you do not get different types if Earths" this is the kind of view i was talking about. Thank you wsaryada for your response.
__________________
dont worry newbie, we got you covered.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UJO Framework 0.72.final JavaBean Java Announcements 0 03-17-2008 10:28 PM
which are the final classes in the java APi vagarwal_mca New To Java 2 01-10-2008 04:47 AM
problem with final sireesha New To Java 1 11-20-2007 03:31 AM
I have a problem with final sireesha New To Java 1 11-20-2007 02:25 AM
Poi 3.0-final levent Java Announcements 0 05-22-2007 09:05 AM


All times are GMT +3. The time now is 01:15 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org