Forums Register Login

java Collections

+Pie Number of slices to send: Send
Any one tell me the easy way to keep difference between collections in mind?
+Pie Number of slices to send: Send
Well, start by getting really good at the ones you will use the most. For example, learn the List interface and ArrayList implementation first. Once you're comfortable with those, you can use that understanding to learn some others, like Map and HashMap. You will start see start to see how things like Trees, Sets, linked lists, etc., all have certain differences that make them better to use in various situations.

Just as a carpenter doesn't learn about all the available tools first before trying to build something, a Java programmer can't hope to learn the whole API from a book (or a forum). Grab some nails and a hammer and start pounding away!
+Pie Number of slices to send: Send
Use the API to draw your own hierarchy chart of the different classes (what's a subclass of what, and what implements what). For each class, list the main advantages and disadvantages (for example, fast insertions in the middle vs. fast random access, etc.).
+Pie Number of slices to send: Send
The main criteria with which the collections differ are ordered, sorted

List - order of elements is guaranteed (ArrayList, LinkedList, Vector)

Set - duplicates not allowed (HashSet,LinkedHashSet, TreeSet)

Tree - Sorted (TreeMap, TreeSet)

Linked kind of data structure, order of elements is guaranteed (LinkedHashMap, LinkedHashSet)

However this can help you to remember only the basic differences. When it comes to detail, i think it will come with regular usage.
+Pie Number of slices to send: Send
+1 for Srikanth Nalam's answer,

To the point, and exactly answers OP's question.
+Pie Number of slices to send: Send
 

salvin francis wrote:
To the point, and exactly answers OP's question.




Unless, of course, the OP is taking an algorithms class... and is trying to remember, the big O values for different types of operations on different collections -- meaning which collections access faster, iterates faster, etc.

Henry
+Pie Number of slices to send: Send
i got some good point to keep collections in mind... thanks a lot.............
The first person to drink cow's milk. That started off as a dare from this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1415 times.
Similar Threads
List in Descending order
Collections
Collections
Garbage collection - arrays
collections and generics
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:12:26.