packagejavaRadarLinkedList;
importjava.util.LinkedList;
public class RemoveAtIndex {
      public static void main(String[] args) {
            //create Array List
            LinkedList<String> javaRadarList = newLinkedList<String>();
            //Add elements to ArrayList
            javaRadarList.add(“Java”);
            javaRadarList.add(“Jquery”);
            javaRadarList.add(“Spring”);
            javaRadarList.add(“Hibernate”);
            javaRadarList.add(“EJB”);
           
            System.out.println(“Before Removal”);
            for(String list : javaRadarList){
                  System.out.println(list);
            }
           
            //Remove element from 2nd position
            javaRadarList.remove(1);
           
            System.out.println(“After Removal”);
            for(String list : javaRadarList){
                  System.out.println(list);
            }
      }
}

OUTPUT:

Before Removal
Java
Jquery
Spring
Hibernate
EJB
After Removal
Java
Spring
Hibernate
EJB

Source link

Remove element from linked list

Leave a Reply

Your email address will not be published. Required fields are marked *