user28314
2
Q:

delete function in linked list java

// Java code to illustrate remove() method 
import java.io.*; 
import java.util.LinkedList; 
  
public class LinkedListDemo { 
    public static void main(String args[]) 
    { 
  
        // Creating an empty LinkedList 
        LinkedList<String> list = new LinkedList<String>(); 
  
        // Using add() method to add elements in the list 
        list.add("Geeks"); 
        list.add("for"); 
        list.add("Geeks"); 
        list.add("10"); 
        list.add("20"); 
  
        // Output the list 
        System.out.println("LinkedList:" + list); 
  
        // Remove the head using remove() 
        list.remove(); 
  
        // Print the final list 
        System.out.println("Final LinkedList:" + list); 
    } 
} 
0

New to Communities?

Join the community