Posts

Showing posts from February 12, 2011

Map.Entry Interface

Map.Entry Interface -     Map.Entry Interface is used to hold the view of key-value pair from Map. Map interface has a method entrySet() which returns the Set object that holds the key value pair. You can iterate the key and value from getKey() and getValue(). You can also set value an element by the setValue() method. List of methods within the Map.Entry Interface -  boolean equals(Object o) -          This method is used to compares the specified object with this entry. If both are equal it return true otherwise return false.  K getKey() -     This method returns the key of map.  V getValue() -     This method returns the value of corresponding to this entry.  int hashCode() -     This method is used to return the hash code value for this map entry.  V setValue(V value) -     This method is used to set the values at  corresponding the key. Example - public class Test {     public static void main(String[] args) {         Map map = new HashMap();         ma

ListIterator Interface

ListIterator Interface -     ListIterator Interface is used for traverse list in both direction. You can find previous element by previous() method and next element by next() method. Within the both method ListIterator maintain the cursor position. ListIterator has previousIndex() for checking that List has previous index or not.      ListIterator Interface extends Iterator Interface. You can also set any new element in the list. List of methods within the ListIterator Interface - void add(E e) -     This method is used to add a given element into the list. boolean hasNext() -     This method is used to check the presence of element in the list when traversing the list in the forward direction. boolean hasPrevious() -     This method is used to check the presence of element in the list when traversing the list in the reverse direction. E next() -     this method is used to return the next element in the list. int nextIndex() -     This method is used for return the i

NavigableSet Interface

NavigableSet Interface -     NavigableSet Interface is very useful for searching strategics. NavigableSet Interface gives the functionality for closest search mechanism. NavigableSet may search less than, less than or equal, greater than or equal, and greater than through the lower, floor, ceiling, and higher methods. There is a example - import java.util.Iterator; import java.util.NavigableSet; import java.util.concurrent.ConcurrentSkipListSet; public class Test {     public static void main(String[] args) {             NavigableSet nSet = new ConcurrentSkipListSet();             nSet.add("A");             nSet.add("B");             nSet.add("C");             nSet.add("D");             nSet.add("E");             nSet.add("F");                         System.out.println(nSet.ceiling("B"));             System.out.println(nSet.floor("B"));             System.out.println(nSet.lower("B&q

Recent Post

Recent Posts Widget