0% found this document useful (0 votes)
7 views1 page

Java LinkedList Operations Example

The document is a Java program demonstrating the use of a LinkedList to store integers. It includes operations such as adding, accessing, checking for presence, and removing elements from the list. The program also displays the contents of the LinkedList at various stages.

Uploaded by

Sourav Kuchlyan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Java LinkedList Operations Example

The document is a Java program demonstrating the use of a LinkedList to store integers. It includes operations such as adding, accessing, checking for presence, and removing elements from the list. The program also displays the contents of the LinkedList at various stages.

Uploaded by

Sourav Kuchlyan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import [Link].

LinkedList;

public class LinkedListDemo {

public static void main(String[] args) {

// Creating a LinkedList of Integers

LinkedList<Integer> linkedList = new LinkedList<>();

// Adding elements to the LinkedList

[Link](10);

[Link](20);

[Link](30);

[Link](40);

// Displaying the elements of the LinkedList

[Link]("Elements in the LinkedList: " + linkedList);

// Adding an element at a specific index

[Link](2, 25);

// Displaying the updated LinkedList

[Link]("Updated LinkedList: " + linkedList);

// Accessing elements using index

[Link]("Element at index 3: " + [Link](3));

// Checking if an element is present

[Link]("Is 15 present? " + [Link](15));

// Removing an element

[Link]([Link](30));

// Displaying the final LinkedList

[Link]("Final LinkedList: " + linkedList);

You might also like