Set (Interface)
- Set is an un-ordered collection which doesn’t allows duplicate (no-duplicate) elements
- We can iterate the values by calling iterator() methodSet set=new HashSet();
Iterator iter = set.iterator();List (Interface)
- List is an ordered collection which allows duplicate elements
- We can iterate the values by calling iterator() methodList list = new ArrayList();
Iterator iter = list.iterator();Map (Interface)
- In Map we used to store the data in key and value pairs, we may have duplicate values but no duplicate keysIn Map we don’t have iterator() method, but we can get the keys by calling the method keySet()Map m; // insert valuesSet s = m.keySet();// Get Map keys into the Set and then iterate this Set object normally// m.keySet() returns Set object with Map keysIterator iter = s.iterator();
No comments:
Post a Comment