Session - 67 (Methods of Collection interface || List interface vs Set Interface)

Опубликовано: 02 Октябрь 2024
на канале: Cubicles Software Testing
184
4

Collection Interface:
Collection interface can store different types of data in form of objects
java.util.Collection
public interface Collection extends Iterable
Collection interface has 3 child interfaces.
a. List
b. Set
c. Queue
Collection provides us set of methods by which we can store different types of data
1. add(Object obj)
2. remove(Object obj)
3. addAll(Collection c)
4. removeAll(Collection c)
5. size() : int
6. isEmpty() : boolean
7. contains(Object obj) : boolean
8. containsAll(Collection c) : boolean
9. clear() : void

List Interface:
1. List uses an indexing concept to add elements (data)
2. List can store duplicate data
3. List can store any number of null data
4. List maintains insertion order


Set Interface:
1. Set uses hashcode concept to add elements(data)
2. Set can not store duplicate data
3. Set can store only single null data
4. Set can not maintain insertion order