


We can remove element from the end of the LinkedList using removeLast function. Planets.addAll(listOf("Mercury", "Venus", "Earth", "Pluto")) In the following example, we are removing the first planet "Mercury" from the planet list using removeFirst function. We can remove element from the start of the LinkedList using removeFirst function. In the following example, we used addLast method to add Pluto planet to the end of the LinkedList. We can add element to the end of the linked list, using addLast method. In the following example we used addFirst method to add Mercury planet to the top of the LinkedList. We can add element to the start of the linked list, using addFirst method. In the following example, we are retrieving the last element and displaying it. We can get the last element of the LinkedList using last member variable. Println("First planet = " + planets.first) In the following example, we are retrieving the first element and displaying it.

We can get the first element of the LinkedList using first member variable. Planets.addAll(listOf("Earth", "Venus", "Mars")) In the following example, we created a linked list of planets. We can create a linkedlist in Kotlin using. It is handled by the the underlying collections framework. So we can add elements and the size will dynamically increase, and if we remove elements, the size will dynamically reduce. Benefit of linked list is that it is faster to insert and delete an element from LinkedList, it doesn't need rearrangement of entire underlying array. It belongs to the Java collections framework. It implements both the List and Deque interface. Public inline fun Collection?.LinkedList provides a doubly linked list data structure implementation. * Returns `true` if this nullable collection is either null or empty. * Returns `true` if the collection is not empty. * Returns the index of the last item in the list or -1 if the list is empty. * Returns an of the valid indices for this collection. Internal expect inline fun buildListInternal( capacity : Int, builderAction : MutableList.() -> Unit): List Return buildListInternal(capacity, "1.3 InlineOnly Internal object EmptyIterator : ListIterator

* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt JvmName( "CollectionsKt ExperimentalTypeInference:: class) and Kotlin Programming Language contributors.
