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] |
[ 0 ] Comments