Can view the tutorials best in Google Chrome, Mozilla Firefox, Opera, higher version of Internet Explorer

Difference between Java Set, List and Map Collections?

Core Java » On Oct 21, 2012 | { 5 Comments }

Let us see the main differences between Set,List,Map java collections..

Set (Interface)

  • Set is an un-ordered collection which doesn’t allows duplicate (no-duplicate) elements
  • We can iterate the values by calling iterator() method

Set s = new HashSet();
Iterator iter = s.iterator();

List (Interface)

  • List is an ordered collection which allows duplicate elements
  • We can iterate the values by calling iterator() method

List li = new ArrayList();
Iterator iter = li.iterator();

Map (Interface)

  • In Map we used to store the data in key and value pairs, we may have duplicate values but no duplicate keys
  • In Map we don’t have iterator() method, but we can get the keys by calling the method keySet()

 

 

What you are thinkig....

5 Responses to “Difference between Java Set, List and Map Collections?”
  1. hussain says:

    Hi sir, could u please explain about jUnit.

  2. kiran says:

    Please make a small correction while explaining about List you misspelled ‘Set’ instead List.

    - Modified

  3. praveen says:

    Please tell the answers in real time scenarios.

  4. vinayak says:

    sir pls explain more details in collection with example

  5. Ajit says:

    Hi Sir!, wait,notify,notifyall methods are related to Thread class then why they are found in Object class,Please explain…..I am waiting …

If you want a pic to show with your comment, go get a gravatar !
Please post your questions on Java4s Answers forum

Name*
Ask a Question ?
or
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Tutorials
Hibernate Recent Posts
Spring Recent Posts
Struts Recent Posts
Recomandded Links Current & UpComing Tutorials Java4s.com
Tutorials Online :
spring Hibernate struts Json Ajax Log4j Log4j
coreJava Servlets


UpComing :
Jsps,Web Services
Java4s is optimized for learning java technologies, all the examples in this site are constantly reviewed to avoid errors. While using this site you agree to have read and accepted our terms of use and privacy policy
Especially i have prepared this blog by keeping fresher's in mind, however it will be very useful for real time developers too.


© 2014 Java4s All rights reserved. | strPro4Tut v(2.0) Theme designed by Team Java4s.