3:35 pm - Saturday August 18, 0981

Stack Example Program for remove(int index)

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(int index).It is used to  remove an element from stack by using index value
*/
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("blue");//to add an element in Stack
s.add("green");//to add an element in Stack
s.add("yellow");//to add an element in Stack
System.out.println(s);
s.remove(2);//to remove an element from stack by using index value
System.out.println("after remove element in index 2:"+s);
}
}

OUTPUT:
[blue, green, yellow]
after remove element in index 2:[blue, green]

BACK

Filed in: Z-A All Java Codes

Comments are closed.