3:53 pm - Friday March 25, 2011

Stack Example Program for isEmpty()

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
boolean isEmpty().It is used to check whether stack is empty or not
*/
import java.io.*;
import java.util.*;
public class StackIsEmpty
{
public static void main(String arg[])throws Exception
{
Stack s=new Stack();//to create object for Stack class
Stack s1=new Stack();//to create object for Stack class
s.add("red");//to add an element in Stack
s.add("blue");//to add an element in Stack
s.add("green");//to add an element in Stack
Boolean b=new Boolean(s.isEmpty());//to check whether stack	 is empty or not
Boolean b1=new Boolean(s1.isEmpty());//to check whether stack is empty or not
System.out.println(s);
System.out.println(b);
System.out.println(s1);
System.out.println(b1);
}
}

OUTPUT:
[red, blue, green]
False
[]
true

BACK

Filed in: Z-A All Java Codes

Comments are closed.