Difference between Set and List Interface in JAVA

Difference between Set and List Interface in JAVA



List

1.List an Ordered grouping of elements i.e.Maintain order of added Element(add the element in List and print on Consol).
2.List can contain duplicate elements
3.New methods are defined inside List interface.


Set

1.Is an Unordered grouping of elements.i.e.not Maintain order of added Element(add the element in List and print on Consol, Order  is changed).
2.Set can contain Unique elements
3.No new methods are defined inside Set interface, so only use Collection interface methods only with Set subclasses.

Post a Comment

1 Comments

  1. Basically, a list collection stores elements by insertion order (either at the end or at a specific position in the list). A list maintains indices of its elements so it allows adding, retrieving, modifying, removing elements by an integer index (zero-based index; the first element is at 0-index, the second at 1-index, the third at 2-index, and so on). The following picture illustrates a list that stores some String elements:
    More Info: selenium training centres in velachery | selenium training institutes in velachery

    ReplyDelete
Emoji
(y)
:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
x-)
(k)