JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java 新手區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 TreeMap的問題!!!!
psychedelic





發文: 8
積分: 0
於 2006-02-13 20:29 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
各位大大
TreeMap是利用
Object put(Object key, Object value)
key來排序

但是如果有相同的key
就是都要存入TreeMap裡
該如何做到呢!?
謝謝~


reply to postreply to post
作者 Re:TreeMap的問題!!!! [Re:psychedelic]
fsyu





發文: 31
積分: 0
於 2006-02-13 20:50 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
從 API 來看,如果有相同的 Key, 後面放進來的(key, value)會蓋過之前的。你如果還是硬要放在 TreeMap,可能有困難。(建議嘗試別的資料結構)

reply to postreply to post
作者 Re:TreeMap的問題!!!! [Re:psychedelic]
cozybreeze





發文: 39
積分: 0
於 2006-03-02 18:50 user profilesend a private message to usersend email to cozybreezereply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
psychedelic wrote:
(恕刪)
但是如果有相同的key
就是都要存入TreeMap裡
該如何做到呢!?
謝謝~


我不理解你要放一樣的key的目的,是不是應該是一樣的value喔,key是用來match的,如果一樣,哪有match可言Question


reply to postreply to post
Java像天使、JavaScript卻像魔鬼=.=
作者 Re:TreeMap的問題!!!! [Re:psychedelic]
alps1982





發文: 17
積分: 0
於 2006-03-03 10:52 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
你可以用containsKey來判斷,是否有重復的key,然後根據你的業務邏輯,做下一步處理

reply to postreply to post
» JWorld@TW »  Java 新手區

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8