8:18 am - Sunday October 21, 2018

Stack Example Program for add(int index,E element)

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 add(int index,E element)
*/
import java.io.*;
import java.util.*;
public class StackInsert
{
public static void main(String args[])
{
Stack s=new Stack();  // to create object for Stack class
s.add(52);    //to add an element in stack
s.add(31);    //to add an element in stack
s.add(56);    //to add an element in stack
System.out.println(s);
s.add(2,96); // Inserts the specified element at the specified position in this Stack.
System.out.println(s);
}
}

OUTPUT:
[52, 31, 96, 56]

BACK

Filed in: Z-A All Java Codes

Comments are closed.