3:42 am - Monday June 25, 2018

Stack Example Program for removeElementAt(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
removeElementAt()
*/
import java.io.*;
import java.util.*;
public class RemoveElementAt
{
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.removeElementAt(2); // Removes element at the specified index
 System.out.println("After removing");
System.out.println(s);
}
}


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

Filed in: Z-A All Java Codes

Comments are closed.