• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Why java.util.AbstractSequentialList has some methods implemented??

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All


While seeing the source code of AbstractSequentialList it looks like it gives implementation of some of the methods ..I am not able to understand why??

Take a look at the declaration of LinkedList class

public class LinkedList<E>
extends AbstractSequentialList<E>
implements List<E>, Deque<E>, Cloneable, java.io.Serializable

LinkedList will inherit all methods of collection,List,AbstractList,AbstractCollection and also AbstractSequentialList.....

It looks like LinkedList class overrides all the implemtations present in AbstractSequentialList...and also AbstractSequentialList is not used anywhere by any other class
Why does it give implemention or say why to have it in first place??


Also I saw same thing in case of AbstractList class ...All subclass whether ArrayList or AbstractSequentialList override the behaviour..
But this class has more to do with vector class which extends its methods and doesn't override it..so that fine..

What is your say on this guys??

Thanks for your help always



 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ryan Raina wrote:Why does it give implemention or say why to have it in first place??


Usually because it's a convenience for the developer.

If you look at the docs for AbstractSequentialList, you'll notice that it says in the very first sentence:
"This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a "sequential access" data store (such as a linked list)."
and I've certainly found the AbstractList class extremely useful.

As to why LinkedList overrides all the implementations, you'd have to ask the designer of the class. I hate to say, but "why" questions like this based on looking at source code will almost always get the same answer, because any guess on our part would be pure speculation.

I'd also suggest that looking at foundation class source code may not be the best use of your time, because the whole point about object-orientation is to hide implementation - and whatever you do, NEVER write programs that rely on source code that you've looked at.

If you want to get information on programming techniques, you'd be far better of getting a decent book on the subject.

Winston
 
Ryan Raina
Greenhorn
Posts: 28
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Winston Gutkowski for your response

My purpose of viewing the source code to to understand the overall architecture of the collection API

I want to learn how to architect a web application from the scratch...so i thought java API might be a good learning...

I know most of the design patters and have used them also but the thing is that I want to understand how one should be able to design an web app from scratch..

Can you suggest some books or material that would help me going about this...I am a good programmer but designing is not my stuff...so kinda want to learn that part...

Anyways I thank you for your response ...specially for this

I'd also suggest that looking at foundation class source code may not be the best use of your time, because the whole point about object-orientation is to hide implementation - and whatever you do, NEVER write programs that rely on source code that you've looked at.



This was useful

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic