10:26 pm - Monday March 27, 2017

Archive: Java Examples Subscribe to Java Examples

To get subset from sorted set

BACK This tutorial explains how  to To get subset from sorted set. To implement your own sorting functionality with TreeSet on user defined objects, you have to pass Comparator object along with TreeSet constructor call. The Comparator implementation...

TreeSet with comparator by user define objects.

BACK This tutorial explains how  to implement TreeSet with comparator by user define objects. To implement your own sorting functionality with TreeSet on user defined objects, you have to pass Comparator object along with TreeSet constructor...

To create a Treeset with Comparator

BACK This tutorial explains how  to implement your own sorting functionality with TreeSet. To implement your own sorting functionality with TreeSet, you have to pass Comparator object     along with TreeSet constructor call. The Comparator...

To find duplicate value from a Treeset.

BACK This tutorial explains how  to find duplicate from  TreeSet. The easiest way to find duplicate entries from the given array is, create TreeSet object and add array entries to the TreeSet. Since the set doesnot support duplicate entries,...

Remove Duplicate Entries from an array using asList()

BACK This tutorial explains how  to Remove Duplicate Entries from an array using asList() method. The easiest way to remove duplicate entries from the given array is, create TreeSet object andadd array entries to the TreeSet. Since the set...

Iterate Treeset elements using Iterator iterator()

BACK This tutorial explains how  to Iterate Treeset elements using  Iterator<E> iterator() method. To read objects using Iterator. By calling iterator() method you will get Iterator object, Through which you can iterate through all...

Add elements to treeset with List add()

BACK This tutorial explains how  to Add elements to treeset using list add() method. create TreeSet with other collection. By passing another collection to the TreeSet constructor, you can copy entire collections elements to the TreeSet. Example import...

Basic Treeset Operations Methods

BACK This tutorial explains how  to do basic Treeset operations. basic operations on TreeSet like creating object, adding elements to it, verifies elements existence, deleting all elements at once, size of the set and deleting a specific element. Example import...

Treeset example programs and Tutorial in java

BACK 1.Basic Treeset Operations Methods 2.Add elements to treeset with List add() 3.Iterate Treeset elements using  Iterator<E> iterator() 4.Remove Duplicate Entries from an array using asList() 5.To find Duplicate Entries from a Treeset...

Clear elements from LinkedList using void clear()

BACK This tutorial explains how  to Clear elements from LinkedList using void clear() method Removes all of the elements from this collection. The collection will  be empty after this     method returns.  We can remove the specific elements...

Remove a Specific Indexed Element from LinkedList by its key V remove(Object key)

BACK This tutorial explains how  to Remove a Specific Indexed Element  from LinkedList by its key using V remove(Object key) method. Removes all of this collection’s elements that are also contained in the specified collection  After...

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

BACK This tutorial explains how  to Remove a data from LinkedList by its key using V remove(Object key) method. Removes a single instance of the specified element from this collection, if it is present  if this collection contains one or...

Add elements to LinkedList using boolean addall(E e)

BACK This tutorial explains how  to Add elements to LinkedList using boolean addall() method. Adds all of the elements in the specified collection to this collection. The behavior of this operation is undefined if the specified collection...

Add elements to LinkedList using boolean add(E e)

BACK This tutorial explains how  to Add elements to LinkedList using boolean add() method. Ensures that this collection contains the specified element.  Returns true if   this collection changed as a result of the call. Example import...

Iterate all elements in Hashset using Iterator()

BACK This tutorial explains how to Iterate all elements in Hashset using Iterator() method. Returns an iterator over the elements in this set.  Iteration will be happen if the element is available at next  level so on. Example import...

Copy all elements from Hashset to an array toArray()

BACK This tutorial explains how to Copy all elements from Hashset to an array  using toArray() method. Another way copy the elements using array concept.  Copy the element up to the number of element reach. Example import java.util.HashSet; public...

Create a copy of Hashset Object clone()

BACK This tutorial explains how to Create a copy of Hashset using Object clone() method. Returns a shallow copy of this HashSet instance: the elements themselves are not cloned.  To get absolute copy of data from one hash variable to another...

Clear elements from Hashset using void clear()

BACK This tutorial explains how  to Clear elements from Hashset using void clear() method. Removes all of the elements from this set. The set will be empty after this call returns.  The hashset contains data only the clear function works. Example import...

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

BACK This tutorial explains how  to check whether a value is present in Hashset using boolean contains() method. True if this set contains the specified element.  To check  whether the element available in hash and return possible boolean...

Get size of Hashset using int size()

BACK This tutorial explains how  to Get size of Hashset using  int size() method. Returns the number of elements in this set (its cardinality).  Whenever we call this method, it checks number of elements in hash table. Example import java.util.HashSet; public...