Description Program to add all the elements of a List to the LinkedList using addAll() method of LinkedList class. Example import java.util.ArrayList; import java.util.LinkedList; import… [Read More]
Java – Get element from specific index of LinkedList example
In this example we are gonna see how to get an element from specific index of LinkedList using get(int index) method: public E get(int index):… [Read More]
Java – Check if a particular element exists in LinkedList example
In this example we are gonna see how to check if a particular element exists in LinkedList using contains() method: public boolean contains(Object o): Returns… [Read More]
Java – Add elements at beginning and end of LinkedList example
Example In this example we will learn how to add elements at the beginning and end of a LinkedList. We will be using addFirst() and… [Read More]
How to convert LinkedList to array using toArray() in Java
Converting LinkedList to array is very easy. You can convert a LinkedList of any type (such as double, String, int etc) to an array of… [Read More]
Java – Convert a LinkedList to ArrayList
Example In this example we are converting a LinkedList to ArrayList. We have a LinkedList of Strings in which we are storing names of 5… [Read More]
Java – Get first and last elements from LinkedList example
In this tutorial we will see an example on how to get first and last element from LinkedList. Example Here we have a LinkedList of… [Read More]
Java – Get sub List from LinkedList example
Example In this example, we are getting a sublist of LinkedList using subList(int startIndex, int endIndex) method of LinkedList class. It returns a List between… [Read More]
Java – Add element at specific index in LinkedList example
In this tutorial we will learn how to add a new element at specific index in LinkedList. We will be using add(int index, Element E)… [Read More]
Java – LinkedList Iterator example
In the last post we learnt how to traverse a LinkedList using ListIterator. Here we will learn how to iterate a LinkedList using Iterator. Example… [Read More]