11:43 am - Wednesday May 24, 2017

Stack Example Program for removeAll(Collection c)

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
/**
 *Stack Example Program for removeAll(Collection c)
 * @author   candidjava.com
 * @description:Removes from this list all of its elements that are contained in the specified collection.
 */
import java.util.*;

public class Line1 {
	public static void main(String args[]) {
		Stack s = new Stack();// creats object for the stack.
		s.push(1);
		s.push(3);
		s.push(4);
		s.push(6);
		System.out.println("before removing" + s);
		s.removeAll(s);// this method removes all the elements in the stack.
		System.out.println("after removing" + s);
	}
}

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

Filed in: Z-A All Java Codes

Comments are closed.