3:09 pm - Wednesday October 21, 0398

Archive: Java Examples Subscribe to Java Examples

Compare two sets in LinkedHashSet using boolean equals(Object o)

BACK                               The method public boolean equals(Object o) compares the two sets and checks  whether the size of sets are same and the elements  present in the sets are equal.Returns true if...

Clear elements from LinkedHashSet using void clear()

BACK                      This tutorial explains how  to Clear elements from LinkedHashSet using void clear() method. Example Program import java.util.LinkedHashSet; public class LinkedHashSetclear { public...

Remove elements using boolean remove(Object o)

BACK The method public boolean remove(Object o) removes the particular element from the linkedhashset,if the element is present.Also,returns true if the element is present,Otherwise returns false. Example Program import java.util.LinkedHashSet; public...

Create duplicate of LinkedHashSet using Object clone()

BACK                                 The method public Object clone () displays the copy of the elements present in the linkedhashset.The cloned set looks same as that of the actual set.The elements themselves...

Get size of LinkedHashSet using int size()

BACK                              The method public int size() displays the number elements present in the linkedhashset. Example Program import java.util.LinkedHashSet; public class LinkedHashSetSize { public...

Iterate LinkedHashSet elements using Iterator iterator()

BACK                             The method public Iterator<E> iterator(), iterates the elements in the linkedhashset using while(it.hasNext()).The elements are returned without a particular order.   Example...

Check whether element present in LinkedHashSet using boolean contains(Object o)

BACK                           The method public boolean contains(Object o) checks whether the specified element is present in the linkedhashset .Returns true if the element is present,otherwise returns false.  Example...

Check whether LinkedHashSet is empty using boolean isEmpty()

BACK                        The method public boolean isEmpty() checks whether the linkedhashset is empty or not. It returns true if the set contains no elements, otherwise it returns false. Example Program import...

Add elements to linkedHashSet using boolean add(E e)

BACK                                   This method adds the specified elements to the set and return true if the elements is added successfully ,Otherwise it returns false. Example Program import java.util.LinkedHashSet; public...

Stack example programs and Tutorial in java

BACK   1.Check whether stack is empty using boolean empty( )   2.Look object at top of the stack using E  peek( )   3.Remove object at the top of stack using E pop()   4.Push an item on top of the stack using E push(E item)   5.Search...

Collections example programs and Tutorial in java

BACK    1. Insert a collection element in already excisting collection using AddAll()    2. View of Deque in Last-in-first-out order using as LifoQueue()    3.  Search a particular list in collection using binarySearch(List<? extends...

LinkedHashSet example programs and Tutorial in java

BACK  1.Add elements to linkedHashSet using boolean add(E e)  2.Check whether  LinkedHashSet is empty using  boolean isEmpty()  3.Check whether element present in LinkedHashSet using  boolean contains(Object o)  4.Iterate LinkedHashSet...

Check two hashtables are equal boolean equals(Object o)

BACK                      This function returns true if the object in the map is equal,otherwise returns false. Example Program import java.util.Hashtable; public class HashtableEquals { public static void...

Get hashCode of a Hashtable int hashCode()

BACK                 This function returns the hash code value for the map. Example Program import java.util.Hashtable; public class HashtableHashCode { public static void main(String args[]) { Hashtable...

Add all data to Hashtable from another Map void putAll(Map t)

BACK                      This method copies all the mappings from the map to the hashtable. Example Program import java.util.Hashtable; public class HashtablePutAll { public static void main(String args[]) { Hashtable...

Remove a data from hashtable by its key V remove(Object key)

BACK This method removes the specified key value from the hashtable. Example Program import java.util.Hashtable; public class Hsht { public static void main(String args[]) { Hashtable htable = new Hashtable(3); htable.put(1,...

Calculate size of Hashtable int size()

BACK                                    This method returns the number of keys in the hashtable. Example Program import java.util.Hashtable; public class HashtableSize { public static void main(String...

Convert hashtable to string String toString()

BACK                                           This function returns a string representation of hashtable in the form of set of entries enclosed in braces and separated by commas. Example Program import...

Retrieve all values in a Hashtable Collection values()

BACK                           This function returns a collection view of the values contained in the map. Example Program import java.util.Hashtable; public class HashtableValues { public static void main(String...

Convert hashtable keys to Set Set keySet()

BACK                                      This method returns set view of the keys contained in the map. Example Program import java.util.Hashtable; public class HashtableKeySet { public static...