Java String Tutorial

String Class is a widely used class in java. String Class represents a bunch of characters and is similar to a character array. String class has almost a dozen constructors and can be used to create String objects. You can check the

Read More

TreeSet descendingIterator method

TreeSet descendingIterator method returns an iterator with the elements sorted in a descending order. When inserting any element into TreeSet it automatically gets sorted into its natural sorting order. TreeSet descendingIterator method is useful when you need a sorted list in descending

Read More

TreeSet ceiling method examples

TreeSet ceiling method returns the closest element greater than or equal to the given element. [crayon-5dabbad6de08e930993884/] Parameters: e – the value to match Returns: the least element greater than or equal to e, or null if there is no such element Throws:

Read More

LinkedHashSet in java basics and internal working

LinkedHashSet in java is part of the Collection framework. It implements the Set interface and extends the HashSet class. LinkedHashSet maintains a doubly-linked list running through all of its entries. This linked list defines the iteration ordering, hence the LinkedHashSet maintains the

Read More

HashSet in java basics and internal working

HashSet in java is part of the Collection framework and implements the Set interface. Few points to remember about HashSet 1. HashSet internally uses HashMap to store elements/objects 2. HashSet stores unique values and one null is allowed 3. HashSet doesn’t guarantee

Read More

CopyOnWriteArrayList listIterator method

The CopyOnWriteArrayList listIterator method returns a list iterator over the elements in the sequence they were inserted. As explained in the previous posts, CopyOnWriteArrayList creates its copy when performing any element changing operations, hence the list iterator returned in the CopyOnWriteArrayList listIterator

Read More

CopyOnWriteArrayList iterator method

The CopyOnWriteArrayList iterator method returns an iterator over the elements in the sequence they were inserted. As explained in the previous posts, CopyOnWriteArrayList creates its copy when performing any element changing operations, hence the iterator returned in the CopyOnWriteArrayList iterator method is

Read More

CopyOnWriteArrayList addAllAbsent method

CopyOnWriteArrayList provides a new method [crayon-5dabbad6df464989454222-i/] , which adds all of the elements in the specified collection that are not already contained in this list, to the end of this list. This is helpful when you need to add only unique elements

Read More

CopyOnWriteArrayList addIfAbsent method

CopyOnWriteArrayList provides a new method [crayon-5dabbad6df876714897582-i/], which adds elements only if that element is not present in the List. This is helpful when you need to add only unique elements into your list. addIfAbsent(E e) method return true if the element is

Read More

Add elements in CopyOnWriteArrayList

In this post we will see how to add elements in CopyOnWriteArrayList using below 2 methods 1. boolean add(E e) Appends the specified element to the end of this list. 2. void add(int index, E element) Inserts the specified element at the

Read More