的搜索(对象O)方法用来返回基于1的位置处的对象在栈上。
import java.util.*;
public class StackDemo {
public static void main(String args[]) {
Stack st = new Stack();
st.push("Java");
st.push("Source");
st.push("code");
System.out.println("Searching 'code' in stack: "+st.search("code"));
}
}输出结果
Searching 'code' in stack: