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

看板java作者 (骨頭)時間19年前 (2006/12/19 02:38), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串4/5 (看更多)
※ 引述《ogamenewbie (._.)》之銘言: : 不太清楚這跟正規式或者 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")) { .matches(".*a.*") 收工XD : System.out.println(st + ": " + hm.get(st)); : } : } -- String temp="relax"; | Life just like programing while(buringlife) String.forgot(temp); | to be right or wrong while(sleeping) brain.setMemoryOut(); | need not to say stack.push(life.running); | the complier will stack.push(scouting.buck()); | answer your life stack.push(bowling.practice()); | Bone everything -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.134.27.68
文章代碼(AID): #15Xk0IWI (java)
文章代碼(AID): #15Xk0IWI (java)