• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java Collections

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any one tell me the easy way to keep difference between collections in mind?
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.).
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
+1 for Srikanth Nalam's answer,

To the point, and exactly answers OP's question.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Selva Prakash
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i got some good point to keep collections in mind... thanks a lot.............
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic