addLast linked list java

LinkedList.AddLast Method

Definition

Adds a new node or value at the end of the LinkedList.

In this article

Overloads

AddLast(LinkedListNode)

Adds the specified new node at the end of the LinkedList.

AddLast(T)

Adds a new node containing the specified value at the end of the LinkedList.

AddLast(LinkedListNode)

Adds the specified new node at the end of the LinkedList.

public: void AddLast(System::Collections::Generic::LinkedListNode ^ node); public void AddLast (System.Collections.Generic.LinkedListNode node); member this.AddLast : System.Collections.Generic.LinkedListNode<'T> -> unit Public Sub AddLast (node As LinkedListNode(Of T))

Parameters

node LinkedListNode

The new LinkedListNode to add at the end of the LinkedList.

Exceptions

ArgumentNullException

node is null.

InvalidOperationException

node belongs to another LinkedList.

Examples

For an example that includes this method, see the LinkedList class.

Remarks

LinkedList accepts null as a valid Value for reference types and allows duplicate values.

If the LinkedList is empty, the new node becomes the First and the Last.

This method is an O(1) operation.

See also

  • AddAfter
  • AddBefore
  • AddFirst
  • RemoveLast()

Applies to

AddLast(T)

Adds a new node containing the specified value at the end of the LinkedList.

public: System::Collections::Generic::LinkedListNode ^ AddLast(T value); public System.Collections.Generic.LinkedListNode AddLast (T value); member this.AddLast : 'T -> System.Collections.Generic.LinkedListNode<'T> Public Function AddLast (value As T) As LinkedListNode(Of T)

Parameters

value T

The value to add at the end of the LinkedList.

Returns

LinkedListNode

The new LinkedListNode containing value.

Examples

For an example that includes this method, see the LinkedList class.

Remarks

LinkedList accepts null as a valid Value for reference types and allows duplicate values.

If the LinkedList is empty, the new node becomes the First and the Last.

This method is an O(1) operation.

See also

  • AddAfter
  • AddBefore
  • AddFirst
  • RemoveLast()

Applies to