J2me - Arrays vs vector?
if we have to implementations of string split for j2me, one returns vector and the other returns array开发者_运维百科 , in terms of performance on hand held devices which one is the best choice ?
Arrays would always perform better than Vector
, although the difference should not be too significant. The real question is whether this performance is worth the sacrifice of not having the rich functionalities provided by Vector
, e.g. being dynamically growable, etc.
Generally speaking you should always prefer List
to arrays (see Effective Java 2nd Edition, Item 25, Prefer lists to arrays), but J2ME development may not give you the luxury.
Vector
is deprecated.
If you don't need to alter the results, use array - it will have less overhead as well as less flexibility.
according to sun j2me performance tuning described in link text
"Arrays are usually faster and leaner than collection classes" , so its clear that using arrays will be much better than any collection object
精彩评论