Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Collections - Internal Working

 
Ak Rahul
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone let me know how the java collections work internally?

For example, how do the collections LinkedList, ArrayList, HashMap, LinkedHashMap, HashSet, LinkedHashSet work?

Does the LinkedList, LinkedHashMap, LinkedHashSet have a single linked list or double linked list internally?

How does hashing work internally in HashMap, LinkedHashMap, HashSet, LinkedHashSet?

The more details the better for me. If you can explain me or direct me to material that explains this, then I shall be really grateful.

Thanks.
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
R Ak wrote:

Please check your private messages for an important administrative matter
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you installed the JDK on your machine.
Look for a file called src.zip in the JDK installation directory. That contains the source code for the Java classes. It should give you a clear picture about the implementation.
 
Ak Rahul
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks maneesh. Can you direct me to some text that explains this, instead of reading the JDK source code, since I also want to know which one has better performance, etc.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15284
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See The Collections Framework, which contains links to several other pages including a Design FAQ.
 
Ulrika Tingle
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rahul Ak wrote:thanks maneesh. Can you direct me to some text that explains this, instead of reading the JDK source code, since I also want to know which one has better performance, etc.


What you need is a general knowledge of the basic standard data structures such as arrays, list, trees and hash tables.

Then you need to look at the Sun API specification to find out the exact properties of a specific collection. It's usually detailed enougth to know what to expect. And by relying on this information only your code becomes implementation independent. This is because the API specifications from Sun work as a standard for the Java language. Trying to "envision" the properties of a collection by seccondguessing its internal workings or looking at an implementation will lead you wrong.
 
Ak Rahul
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for all responses. I really appreciate your help.


regards,
Rahul
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic