9:03 pm - Monday October 15, 2018

Stack Example Program for removeAllElements()

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
/**
 *@author :CandidJava.com
 *@descriptions : This program explain the function and use of
removeAllElements()
 */
import java.io.*;
import java.util.*;

public class RemoveAllElement {
	public static void main(String arg[]) throws Exception {
		Stack s = new Stack(); // to create object for Stack class
		s.add(50); // to add an element in Stack
		s.add(60); // to add an element in Stack
		s.add(70); // to add an element in Stack
		s.add(80); // to add an element in Stack
		System.out.println(s);
		s.removeAllElements(); // removes all elements in stack
		System.out.println("After removing");
		System.out.println(s);
	}
}

OUTPUT:
[50,60,70,80]
After removing
[ ]

Filed in: Z-A All Java Codes

Comments are closed.