3:29 pm - Sunday June 21, 7637

Stack Example Program for setElementAt(E obj,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
SetElementAt()
*/
import java.io.*;
import java.util.*;
public class SetElementAt
{
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.setElementAt(90,2); // Sets the component at the specified index
System.out.println("After Setting");
System.out.println(s);
}
}


OUTPUT:
[50,60,70,80]
After Setting
[50,60,90,80]

Filed in: Z-A All Java Codes

Comments are closed.