Remove an Element at specified index from LinkedList

Remove an Element at specified index from LinkedList


Posted in : Java Posted on : November 29, 2010 at 5:34 PM Comments : [ 0 ]

This Java Example shows how to remove an element at the specified index in the specified LinkedList object in java.

Remove an Element at specified index from LinkedList Example

This Java Example shows how to remove an element at the specified index in the specified LinkedList object  in java. To remove the element from LinkedList object we use Object remove(int index) method. This method returns the element removed from the LinkedList.

 Example: RemoveElementat.java

package devmanuals.com;

import java.util.*;

public class RemoveElement {
	public static void main(String[] args) {

		LinkedList LKLST = new LinkedList();
		LKLST.add("2");
		LKLST.add("3");
		LKLST.add("4");
		System.out.println("Before removing : " + LKLST);
		LKLST.remove(1);
		System.out.println("After removing  : " + LKLST);

	}
}

Output:

Before removing : [2, 3, 4] 

After removing : [2, 4]

Download The Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics