3:39 am - Saturday August 19, 2017

LinkedList Example Program for remove(Object o)

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(Object o)
/**
* @author   candidjava.com
* @description: //this method removes the first occurrence of the specified  element from this list.
*/

import java.util.LinkedList;

public class Link {
public static void main(String args[]) {
LinkedList l = new LinkedList();// create object for linkedlist.
l.add("e");
l.add("f");
l.add("d");
l.add("s");
l.add("a");
l.add("d");
System.out.println("before removing" + l);
l.remove("d");// removes first occurence of the specified object from
// list.
System.out.println("after removing:" + l);
}
}

<span style="color: #3366ff;">Output:</span>
before removing[e, f, d, s, a, d]
after removing:[e, f, s, a, d]

BACK

 

Filed in: Z-A All Java Codes

Comments are closed.