3:41 am - Saturday August 19, 2017

LinkedList Example Program for remove(int index)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

//LinkedList Example Program for remove(int index)
/**

* @author   candidjava.com
* @description:Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices).
Returns the element that was removed from the list.

*/


import java.util.*;
public class List
{
public static void main(String args[])
{
try
{
LinkedList l=new LinkedList();//creats objects for linkedlist.
l.add(1);
l.add(3);//add the elements.
l.add(4);
l.add(6);
System.out.println("before removing" +l);
l.remove(3);//this method is used for removes the element from specified position.
System.out.println("after removing"+l);
}
catch(Exception a)
{
}
}
}

Output:

before removing[1, 3, 4, 6]
after removing[1, 3, 4]

BACK

Filed in: Z-A All Java Codes

Comments are closed.