7:06 am - Thursday December 13, 2018

Stack Example Program for contains(Object o)

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 contains(Object o)
*/
import java.io.*;
import java.util.*;
public class StackContains
{
public static void main(String args[])
{
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
s.add("yellow");     //to add an element in stack
boolean b=s.contains("red"); // Returns true if this stack contains the specified element
System.out.println(b);
System.out.println(s);
}
}

OUTPUT:
true
[blue, green, red]

BACK

Filed in: Z-A All Java Codes

Comments are closed.