3:53 pm - Saturday March 24, 6474

Stack Example Program for size()

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  setSize().
*/
import java.io.*;
import java.util.*;
public class StackSetSize
{
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("red"); //to add an element in Stack
System.out.println(s);
System.out.println("Size of the stack is: " + s.size());
s.setSize(5); //increases the size of this stack
System.out.println("New size of the stack is:" +s.size());
}
}

OUTPUT:
[blue, green, red]
Size of the stack is:3
New size of the stack is:5

BACK

Filed in: Z-A All Java Codes

Comments are closed.