search(Object o) 方法在 java 中的作用是什麼?


search(Object 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: 

更新於:2020 年 2 月 25 日

337 次瀏覽

開啟你的 職業生涯

完成課程以獲得認證

開始
廣告
© . All rights reserved.