3:44 pm - Friday December 11, 1136

Stack Example Program for setSize(int newSize)

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
int  size(). This function used to to return number of element in the stack
*/
import java.io.*;
import java.util.*;
 public class StackSize
{
public static void main(String arg[])throws Exception
{
Stack s=new Stack();//to create object for Stack class
s.add(500);//to add an element in Stack
s.add(600);//to add an element in Stack
s.add(700);//to add an element in Stack
s.add(800);//to add an element in Stack
System.out.println(s);
System.out.println("Size is "+s.size());//to return number of element in the stack
}
}

OUTPUT:
[500, 600, 700, 800]
Size is 4

BACK

Filed in: Z-A All Java Codes

Comments are closed.