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

» JWorld@TW » Java ME、Google Android 平台與 JavaCard 討論區  

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





發文: 51
積分: 0
於 2004-08-06 15:40 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
原始碼是

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;
public class HashTableTest extends MIDlet
{
  public HashTableTest()
  {
  }
  public void startApp()
  {
    Hashtable ht = new Hashtable();
    ht.put("3",new Integer(11));
    ht.put("19",new Integer(66));
    ht.put("0",new Integer(55));
    ht.put("77",new Integer(100));
    
    System.out.println("Value of key 19 is " + ht.get("19"));
    
    Enumeration e = ht.elements();
    while(e.hasMoreElements())
    {
      System.out.println(e.nextElement());
    }
  }
  
  public void pauseApp()
  {
  }
  
  public void destroyApp(boolean unconditional)
  {
  }
}


執行結果是
1
2
3
4
5
6
7
8
9
10
Value of key 19 is 66
 
11
 
55
 
66
 
100
 


想請問的是

原本放入的順序是66在55之前

為何經由Enumeration介面存取出來的順序卻是先55再來才是66呢@@?

初學不太懂...麻煩各位指導小弟一下^^"


reply to postreply to post
作者 Re:請問關於Hashtable的問題 [Re:tedinroc]
tekwei

系統穩定



發文: 978
積分: 4
於 2004-08-06 16: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
內部經過sorting~
詳細可以在google搜索Enumeration Sort


tekwei edited on 2004-08-06 17:01
reply to postreply to post
作者 Re:請問關於Hashtable的問題 [Re:tedinroc]
tedinroc





發文: 51
積分: 0
於 2004-08-06 20:59 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
感謝^^

我了解了Smile


reply to postreply to post
作者 Re:請問關於Hashtable的問題 [Re:tedinroc]
huangbx





發文: 1
積分: 0
於 2005-05-29 09:46 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
具体怎么解决的?我也遇到了同样的问题,谢谢!

reply to postreply to post
» JWorld@TW »  Java ME、Google Android 平台與 JavaCard 討論區

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