To remove elements from LinkedList in Java
linkedList.remove(object);//remove by object linkedList.remove(index); //remove by index
Full source
import java.util.Arrays; import java.util.LinkedList; public class Main { public static void main(String args[]) { // Create an array list. LinkedList<String> al = new LinkedList<String>(); /*from www.j a va 2 s .co m*/ // Add elements to the array list. al.add("SQL"); al.add("Java"); al.add("Javascript"); al.add("CSS"); al.add("HTML"); al.add("Demo2s.com"); al.add(1, "Hi"); System.out.println(al); // Remove elements from the linked list. al.remove("CSS"); al.remove(2); System.out.println("Contents after deletion: " + al); } }