Re: [問題] 請問如何將正規表示法用在 HashMap.get()

看板java作者 (._.)時間19年前 (2006/12/18 21:42), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/5 (看更多)
不太清楚這跟正規式或者 get 的關係... 我通常是這樣做... HashMap<String, String> hm = new HashMap<String, String>(); hm.put("a","1"); hm.put("b","2"); hm.put("xax","3"); hm.put("ax","4"); hm.put("xa","5"); Iterator it = new Vector<String>(hm.keySet()).iterator(); while (it.hasNext()) { String st = it.next().toString(); if (st.contains("a")) { System.out.println(st + ": " + hm.get(st)); } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.25.148.49
文章代碼(AID): #15XfgrXk (java)
文章代碼(AID): #15XfgrXk (java)