Pragmatic Coder

best practices
posts - 8, comments - 0, trackbacks - 0, articles - 0

Java tips(1): Vector to Array

Posted on 2006-07-17 17:07 肖鹏 阅读(259) 评论(0)  编辑  收藏

1.
       vectorObj.trimToSize();   //(optional) insure you won't have empty elements
       ArrayObj[] objs = new ArrayObj[vectorObj.size()];
       vectorObj.toArray(objs);
       return objs.
2.
       Object[] tempObjectArray = vectorObj.toArray();
       ArrayObj[] objs = new ArrayObj[ tempObjectArray.size() ];
       System.arraycopy (tempObjectArray, 0, objs, 0, objs.size() );
       return objs;


只有注册用户登录后才能发表评论。


网站导航:
博客园   IT新闻   Chat2DB   C++博客   博问