import java.util.*;
class Stacksearch
{
public static void main(String args[])
{
Stack<String> s=new Stack<>();
//push the elements(inserting elements)
s.push(“Apple”);
s.push(“Banana”);
s.push(“cherry”);
System.out.println(“the elements are: +s);
String searchelement=”cherry”;
int position=s.search(searchelement);
if(position != -1)
{
System.out.println(searchelement +”found at the position(from top)” +position);
}
else
{
System.out.println(searchelement +”not found inside the stack”);
}
}}