Set : This interface doesn't difine any additional methods after extending collection. All the implementation of set defines add methods in such a way that duplicat element are not added i.e. a set in a named index collection of unique element.
Hash Set and Tree Set clases produce implementation of set interface through abstract class. Basic difference between hash set and tree set is in their undefined data structure.
Hash set uses a has table for string element and tree set uses binary search tree.
Example : TreeSet Or Hash Set
Map : A map is a collection of paired element in a map values are stored by associating them to a key which act as an index.
Map interface describe the functionality of a map. IT contains follwing methods.
=> Put() : used to store keyvalue pair in a map.
Syntax : public boolean put(object key);
=> get() : used to obtain a value of a map.
Syntax : public Object get(Objec key);
=> remove() : is used to remove a key value paired from a map.
Syntax : public Object remove(Object key);
=> containKey() : is used to search a key from a map.
Syntax : public boolean containKey(Object key);
=> catains() : is used to search a value from a map.
Syntax : public Object contains(Object key);
=> size() : used to find out a number of entries in a map.
Syntax : public int size();
=> clear() : used to remove all the entries from the map.
Syntax : public Map clear();
=> keySet() : returns a set valur for all the key of map.
Syntax : public set keySet();
=> entrySet() : returns a set view for all the entries of map.
Syntax : public Set entryeSet();
0 Comments:
Post a Comment