3:44 pm - Saturday December 11, 3266

Stack 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
/**
*@author :CandidJava.com
*@descriptions : This program explain the function and use of
remove(Object o).It is used to  check whether first occurence of given element is removed from stack or not
*/
import java.io.*;
import java.util.*;
 public class StackRemove
{
public static void main(String arg[])throws Exception
{
Stack s=new Stack();//to create object for Stack class
s.add("a");//to add an element in Stack
s.add("b");//to add an element in Stack
s.add("c");//to add an element in Stack
s.add("a");//to add an element in Stack
System.out.println(s.remove("a"));//to check whether first occurence of given element is removed from stack or not
}
}

OUTPUT:
true

BACK

Filed in: Z-A All Java Codes

Comments are closed.