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

» JWorld@TW » Java SE 討論區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 Re:J2SE 1.5 的新特点 [Re:tempo]
saijone

Web Services

版主

發文: 470
積分: 24
於 2003-08-07 03:20 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
tempo wrote:
我們可不可以先把 int 用 Integer 表示, 這樣比較清楚..

1
2
3
Hashtalbe<String, Integer> map = new Hashtable<String, Integer>();
map.put("abc", new Integer(3));
Integer i = map.get("abc");


假設有一個 precompiler 會先把它轉成:

1
2
3
Hashtalbe map = new Hashtable();
map.put("abc", new Integer(3));
Integer i = (Integer)map.get("abc");


然後再拿這段 code 去 compile, compiler 就不需要知道額外的資訊了..


I guess this is exactly what the prototype is doing. I doubt JVM will be
changed to accommodate this new feature shortly. Because bytecode will
need to contain more things (type information and casting logic),
performance may be sacrified a little bit.

If JVM/Runtime is not changed, you could call all of these new features
compiler sugar. Though it may make you fatter, sugar is sweet. I do not
think we need to care too much about performance for this point,
because the benefit of this feature is relatively significant.

What did I mean by "compile-time" checking is that, if you declare
1
List<String> words = new ArrayList<String>();

then compile will allow you to do
1
String title = words.get(i).toUppercase();

but compile should complain if you do following:
1
Integer i = (Integer)words.get(i);


Additionally, this is what I think, if you have following method:
1
public String getItem(int i, List<String> l)

Compiler should complain if this method is called or implemented by
getItem(int i, List<Integer> l) or getItem(int i, List l) .

The Specification does NOT allow <primitive-type-list>, so, "Vector<int>"
should be illegal.


reply to postreply to post
You don't need a reason to help people
話題樹型展開
人氣 標題 作者 字數 發文時間
16268 [精華] J2SE 1.5 的新特点 subbug 2433 2003-08-02 09:30
15091 Re:J2SE 1.5 的新特? piggy 311 2003-08-02 11:53
15261 Re:J2SE 1.5 的新特点 saijone 3765 2003-08-02 22:52
13838 Re:J2SE 1.5 的新特点 Duncan 689 2003-08-06 22:58
13691 Re:J2SE 1.5 的新特点 popcorny 1058 2003-08-06 23:17
13580 Re:J2SE 1.5 的新特点 tempo 667 2003-08-06 23:28
13586 Re:J2SE 1.5 的新特点 popcorny 675 2003-08-07 00:18
13776 Re:J2SE 1.5 的新特点 Duncan 1016 2003-08-07 00:35
14380 Re:J2SE 1.5 的新特点 popcorny 933 2003-08-07 00:57
13538 Re:J2SE 1.5 的新特点 Duncan 699 2003-08-07 08:59
13362 Re:J2SE 1.5 的新特点 tempo 387 2003-08-07 01:15
13565 Re:J2SE 1.5 的新特点 saijone 1722 2003-08-07 03:20
13329 Re:J2SE 1.5 的新特点 worookie 458 2003-08-07 05:56
13511 Re:J2SE 1.5 的新特点 Duncan 894 2003-08-07 09:06
13185 Re:J2SE 1.5 的新特点 worookie 149 2003-08-07 09:20
13461 Re:J2SE 1.5 的新特点 Duncan 194 2003-08-07 09:24
13199 Re:J2SE 1.5 的新特点 worookie 191 2003-08-07 09:34
13311 Re:J2SE 1.5 的新特点 saijone 660 2003-08-07 10:49
13494 Re:J2SE 1.5 的新特点 popcorny 267 2003-08-07 10:58
13185 Re:J2SE 1.5 的新特点 tempo 845 2003-08-07 11:27
13667 Re:J2SE 1.5 的新特点 Dream 1620 2003-10-05 01:56
13676 Re:J2SE 1.5 的新特点 Duncan 882 2003-08-07 00:21
13357 Re:J2SE 1.5 的新特点 tempo 434 2003-08-07 01:22
13251 Re:J2SE 1.5 的新特点 worookie 104 2003-08-07 02:04
13303 Re:J2SE 1.5 的新特点 popcorny 147 2003-08-07 11:02
13207 Re:J2SE 1.5 的新特点 tempo 157 2003-08-07 11:20
13101 Re:J2SE 1.5 的新特点 worookie 144 2003-08-07 14:04
13281 Re:J2SE 1.5 的新特点 worookie 169 2003-08-07 02:24
13340 Re:J2SE 1.5 的新特点 worookie 246 2003-08-07 01:29
13491 Re:J2SE 1.5 的新特点 popcorny 1947 2003-08-07 10:50
13269 Re:J2SE 1.5 的新特点 tempo 811 2003-08-07 11:19
14708 Re:J2SE 1.5 的新特点 saijone 764 2003-08-07 12:12
» JWorld@TW »  Java SE 討論區

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

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8