Java Stack.search(Object o)

Syntax

Stack.search(Object o) has the following syntax.

public int search(Object o)

Example

In the following code shows how to use Stack.search(Object o) method.


//w  ww . j  a va2  s.  co m

import java.util.Stack;

public class Main {
   public static void main(String args[]) {
      
      Stack st = new Stack();
      
      st.push("Java");
      st.push("Source");
      st.push("from java2s.com");

      System.out.println(st.search("Source"));
   }    
}

The code above generates the following result.