Remove first and last element from LinkedList in Java

In this tutorial, we will learn how to Remove first and last element from LinkedList in Java. LinkedList in Java is doubly-linked list implementation of the List and Deque interfaces. LinkedList class extends AbstractSequentialList and implements the List, Deque, and Queue interfaces and permits null elements. It provides a linked-list data structure. If we want to remove first and last element from LinkedList in Java, then this class provides two methods removeFirst() and removeLast() to remove first and last element from LinkedList. We will use these method to remove first and last element from LinkedList. The syntax…

Read More

Get tailset from TreeSet in Java

In this tutorial, we will learn how to Get tailset from TreeSet in Java. TreeSet in Java extends AbstractSet and implements the NavigableSet interface. It creates a collection that uses a tree for storage. The objects are stored in sorted, ascending order. Access and retrieval times are quite fast, which makes TreeSet an excellent choice when storing large amounts of sorted information that must be found quickly. TreeSet is similar to HashSet, the difference is that TreeSet sorts the elements in ascending order and doesn’t allow null elements. TreeSet class in…

Read More

Get subset from TreeSet in Java

In this tutorial, we will learn how to Get subset from TreeSet in Java. TreeSet in Java extends AbstractSet and implements the NavigableSet interface. It creates a collection that uses a tree for storage. The objects are stored in sorted, ascending order. Access and retrieval times are quite fast, which makes TreeSet an excellent choice when storing large amounts of sorted information that must be found quickly. TreeSet is similar to HashSet, the difference is that TreeSet sorts the elements in ascending order and doesn’t allow null elements. TreeSet class in…

Read More

How to Reverse LinkedList in Java ?

In this tutorial, we will learn how to Reverse LinkedList in Java. LinkedList in Java is doubly-linked list implementation of the List and Deque interfaces. LinkedList class extends AbstractSequentialList and implements the List, Deque, and Queue interfaces and permits null elements. It provides a linked-list data structure. If we want to reverse an LinkedList, then Collections class in Java provides a method reverse() to reverse a LinkedList. The syntax of reverse() method is: Syntax of reverse() method:

this method reverses the order of the elements in the specified list. Parameters: list – the…

Read More

How to Reverse ArrayList in Java ?

In this tutorial, we will learn how to Reverse ArrayList in Java. ArrayList in Java is a resizable-array implementation of the List interface. ArrayList in Java implements all optional list operations, and permits all elements, including null. In addition to implementing the List interface, this class provides methods to manipulate the size of the array that is used internally to store the list. The ArrayList class extends AbstractList and implements the List interface. ArrayList supports dynamic arrays that can grow as needed. Standard Java arrays are of a fixed length. After…

Read More

Get SubList from LinkedList in Java

In this tutorial, we will learn how to Get SubList from LinkedList in Java. LinkedList in Java is doubly-linked list implementation of the List and Deque interfaces. LinkedList class extends AbstractSequentialList and implements the List, Deque, and Queue interfaces and permits null elements. It provides a linked-list data structure. In order to get sublist from LinkedList in Java, this class provides a method subList() to get sublist from LinkedList in Java. The syntax of subList() method is: Syntax of subList() method:

Parameters: startIndex- sublist containing elements from start index inclusive. endIndex- sublist…

Read More

Add elements at beginning and end of LinkedList in Java

In this tutorial, we learn how to add elements at beginning and end of LinkedList in Java. LinkedList in Java is doubly-linked list implementation of the List and Deque interfaces. LinkedList class extends AbstractSequentialList and implements the List, Deque, and Queue interfaces and permits null elements. It provides a linked-list data structure. LinkedList class in Java provides addFirst() and addLast() methods to add elements at beginning and end of LinkedList. The syntax of addFirst() and addLast() method is: Syntax of addFirst() method:

this method inserts the specified element at the beginning of…

Read More

Remove specific element from LinkedList in Java

In this tutorial, we will learn how to Remove specific element from LinkedList in Java. LinkedList in Java is doubly-linked list implementation of the List and Deque interfaces. LinkedList class extends AbstractSequentialList and implements the List, Deque, and Queue interfaces and permits null elements. It provides a linked-list data structure. If we want to remove a specific element from LinkedList in Java, then this class provides remove() method to remove specific element. We will use this method to remove specific element from LinkedList. The syntax of remove() method is: Syntax of remove() method:

Read More

Remove specific element from TreeSet in Java

In this tutorial, we will learn how to Remove specific element from TreeSet in Java. TreeSet in Java extends AbstractSet and implements the NavigableSet interface. It creates a collection that uses a tree for storage. The objects are stored in sorted, ascending order. Access and retrieval times are quite fast, which makes TreeSet an excellent choice when storing large amounts of sorted information that must be found quickly. TreeSet is similar to HashSet, the difference is that TreeSet sorts the elements in ascending order and doesn’t allow null elements. If we…

Read More

Remove specific element from LinkedHashSet in Java

In this tutorial, we will learn how to Remove specific element from LinkedHashSet in Java. LinkedHashSet in Java is Hash table and linked list implementation of the Set interface. It extends HashSet and implements Set interface. LinkedHashSet maintains a linked list of the entries in the set, in the order in which they were inserted. This allows insertion-order iteration over the set. That is, when iterating through a LinkedHashSet using an iterator, the elements will be returned in the order in which they were inserted. If we want to remove a specific element…

Read More