[go: up one dir, main page]

0% found this document useful (0 votes)
28 views3 pages

Mitin .It

The collection interface in Java provides a framework for storing and manipulating groups of objects. There are three main interfaces that extend collection: List, Set, and Map. List represents an ordered collection of elements that can contain duplicates. Set represents a collection of unique elements with no duplicates. Map represents a collection of key-value pairs, with no duplicate keys and each key mapping to at most one value.

Uploaded by

alemreta5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views3 pages

Mitin .It

The collection interface in Java provides a framework for storing and manipulating groups of objects. There are three main interfaces that extend collection: List, Set, and Map. List represents an ordered collection of elements that can contain duplicates. Set represents a collection of unique elements with no duplicates. Map represents a collection of key-value pairs, with no duplicate keys and each key mapping to at most one value.

Uploaded by

alemreta5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

The collection in java is the root interface of the collection framework

and provide several classes and interfaces to represent a group of


individual objects as a single unit. List, Set, and Queue are the main
child interfaces of the collection interface.

The Collection in Java is a framework that provides an architecture to store and


manipulate the group of objects.

Java Collections can achieve all the operations that you perform on a data such as
searching, sorting, insertion, manipulation, and deletion.

List
A List in java extends the collection interface and represent an
sequenced or ordered group of elements. It can contain duplicate
elements. It also defines some additional methods which it inherits
from Collection interface.

Note: Elements in List can be inserted, updated, or retrieved


by their position or index. Index or position value starts from 0.
Set
A set represents a group or collection of items. Set has a special
property that is unique items, it can not contain a duplicate item or
element. It extends the collection interface.

Note: Set interface does not have any additional method other
than methods inherited from Collection interface. With all
collection interface methods it adds the restriction that it can
not contain a duplicate elements.
Map
A map in java, not extends the Collection interface. It represents a
group of special elements or objects. Every map element or object
contains key and value pair. A map can’t contain duplicate keys and
one key can refer to at most one value.
Difference between List, Set, and Map in Java
List Set Map

The list
interface
Set does not allow
allows The map does not allow duplicate elements
duplicate elements.
duplicate
elements

The list
maintains Set do not maintain The map also does not maintain any
insertion any insertion order. insertion order.
order.

We can
add any But in set almost only The map allows a single null key at most
number of one null value. and any number of null values.
null values.

List
implement Set implementation
ation classes Map implementation classes
classes are HashSet, Linked are HashMap, HashTable, TreeMap, Conc
are Array HashSet, urrentHashMap, and LinkedHashMap.
List, Linked and TreeSet.
List.

The list
provides
get() Set does not provide
method to get method to get the The map does not provide get method to
get the elements at a get the elements at a specified index
element at specified index
a specified
index.

If you need If you want to create If you want to store the data in the form of
to access a collection of unique key/value pair then we can use the map.
List Set Map

the
elements
frequently
by using elements then we can
the index use set
then we
can use
the list

To traverse
the list Iterator can be used
elements traverse the set Through keyset, value, and entry set.
by using elements
Listlterator.

You might also like