About an instance of the Vector class and add an element
Please wait 十二月 15th, 2009 by ㄚ琪 | |2009/12/15
不知是我英文不好不懂題意,還是這個題目出的有問題,讓我看了答案有點疑問?
答案是這樣:
4) Vector v=new Vector(100);
v.addElement(“99″)
A vector can only store objects not primitives. The parameter “99″ for the addElement method pases a string object to the Vector. Option 1) creates a vector OK but then uses array syntax to attempt to assign a primitive. Option 2 also creates a vector then uses correct Vector syntax but falls over when the parameter is a primitive instead of an object.
為什麼我用eclipse 3.5.1+java 1.6來編譯,2,3,4都可以執行,感覺add是指增加一個元素,而addElement可以增加較多個,但在此例是一樣的,另外解答說不可以使用primitive型別,可是卻又可以使用,但查考手冊沒有特別提到不可以,所以這個說明就有點奇怪了,看倌是否有更好說明可以幫我瞭解的!
歷史上的今天
- 2011: 專業級的MS-BIO 系統保養
- 2011: 找工作-yes123人力資源網
- 2011: Quick Loans Online
- 2011: Quality Diapers for Adults
- 2011: 聖誕下殺「團購價」!titan運動襪,現在買省最多
- 2010: The Introduction of The Mythical Man-Month
- 2010: Be of Good Cheer
- 2009: Guard Against A PC Spy
- 2009: 二顧茅廬求遠傳大寬頻
- 2009: 帥哥美女揪團去













