3:58 pm - Saturday February 25, 2017

Archive: Java Examples Subscribe to Java Examples

check whether Hashset is empty using boolean isEmpty()

BACK This tutorial explains how  to check whether  Hashset is empty using boolean isEmpty() method. Returns True if this set contains no elements. To check hashset whether empty or not and return result in Boolean value. Example import java.util.HashSet; public class CheckEmpty { public static void main(String...

Remove elements from Hashset using boolean remove(Object o)

BACK This tutorial explains how  to Remove elements from Hashset using  boolean remove(Object o) method. True if the set contained the specified element To remove the particular element in the hashset using hashset variable.remove() Example import java.util.HashSet; public class AddDuplicate { ...

Add elements to HashSet using boolean add(E e)

BACK This tutorial explains how  to Add elements to HashSet using boolean add() method. True if this set did not already contain the specified element.  Duplicate element three did not add in the list more than once. When you repeat the...

Hashset example programs and Tutorial in java

BACK 1.Add elements to HashSet using boolean add(E e) 2.Remove elements from Hashset using  boolean remove(Object o) 3.check whether  Hashset is empty using boolean isEmpty() 4.Get size of Hashset using  int size() 5.check whether a value...

check whether all values are present in LinkedList boolean containsAll(Object value)

BACK This tutorial explains how  to check whether all values are  present in LinkedList using boolean containsAll() method. To check the arr contains all elements which are  list contains. Example import java.util.LinkedList; public class...

check whether a value is present in LinkedList boolean contains(Object value)

BACK           This tutorial explains how  to check whether a value is present in LinkedList using boolean contains() method.The specific elements is matched with collection elements it matches means it returns  true. Example import...

check whether LinkedList is empty using Another way boolean isEmpty()

BACK        This tutorial explains how  to check whether  LinkedList is empty using another way boolean isEmpty() method. Example import java.util.LinkedList; public class CheckElementempty { public static void main(String a[]) { ...

check whether LinkedList is empty using boolean isEmpty()

BACK            This tutorial explains how  to check whether  LinkedList is empty using boolean isEmpty() method. If you pass null value to the element isEmpty() treat that as data.Returns only the boolean result only. Example import...

Get size of LinkedList using int size()

BACK             This tutorial explains how  to Get size of LinkedList using  int size() method. The number of elements in this collection.index value start from 1. Example import java.util.LinkedList; public class ElementSize { public...

LinkedList example programs and Tutorial in java

Check whether a key is avilable in Treemap boolean containsKey(Objectkey)

BACK This tutorial explains how  to Check whether a key is avilable in Treemap using boolean containsKey() method.It checks the specified key contains the value. Example import java.util.TreeMap; class TreeMapContains { public static...

Return a view of the portion of this map headMap(K toKey, boolean inclusive)

BACK      This tutorial explains how  to Return a view of the portion of this map using headMap(K toKey,     boolean inclusive) method.inclusive–This is true if the high endpoint is to be included in the returned view. Example import...

Retrieve all values in a Treemap Collection values()

BACK                             This tutorial explains how  to Retrieve all values in a Treemap  Collection<V> values().  The sorting may be happen based on the values and also key too. Example import...

To Check First and Last Key in TreeMap using lastkey() & firstkey()

BACK This tutorial explains how  to find first and last key in treemap using firstkey() & lastkey() method.The same    way first value also checked among the list.If the value is found means just return the value. Example import java.util.Comparator; import...

Get size of Treemap using int size()

BACK                        This tutorial explains how  to Get size of Treemap using  int size() method.Count the number of elements in the tree map using size() function. Example import java.util.TreeMap; public...

Create a copy of treemap Object clone()

BACK                                  This tutorial explains how to Create a copy of treemap using Object clone() method.It will make copy of the whole key and values. Example import java.util.TreeMap; public...

clear all elements from treemap void Clear()

BACK                       This tutorial explains how to clear all elements from treemap using Clear() method. we can’t clear the particular data ,it will clear    all the data. Example import java.util.TreeMap; public...

clear all elements from treemap void Clear()

clear all elements from treemap void Clear()

BACK               This tutorial explains how to clear all elements from treemap using Clear() method. we can’t clear the particular data, it will clear all the data. Example : import java.util.TreeMap; public class TreeMapClear {         public static void main(String...

Create a copy of treemap Object clone()

BACK           This tutorial explains how to Create a copy of treemap using Object clone() method.  It will make copy of the whole key and values.   Examples : import java.util.TreeMap; public class  TreeMapClone {         public static void main(String...