12:46 am - Monday August 21, 2017

LinkedList Example Program for remove Last Occurrence(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 removeLastOccurrence(Object o)
/**
* @author   candidjava.com
* @description: Removes the last occurrence of the specified element in this list
(when traversing the list from head to tail).If the list does not contain the element, it is unchanged.
*/
import java.util.LinkedList;

public class List2 {
public static void main(String args[]) {
LinkedList l = new LinkedList();// create object for linkedlist.
l.add("e");
l.add("f");
l.add("d");// add elements in list.
l.add("s");
l.add("s");
l.add("d");
System.out.println("Before removing" + l);
l.removeLastOccurrence("s");// this function used for Removes the last
// occurrence of the specified element in
// list.
System.out.println("after removing" + l);
}
}
<span style="color: #3366ff;">Output:</span>
Before removing[e, f, d, s, s, d]
after removing[e, f, d, s, d]

Output:
Before removing[e, f, d, s, s, d]
after removing[e, f, d, s, d]

BACK

 


							
							
			
Filed in: Z-A All Java Codes

Comments are closed.