Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

array list and string[]

 
pippiri venu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which one is the best?
and why?

array list or string[]
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends greatly on what you're doing with it. Arrays offer slightly better performance (there is less overhead to deal with), but ArrayList is more flexible (you can add and delete elements).
I prefer Collections for their convenience, which to me is almost always more important than speed.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before Java 5.0, arrays also provided type-checking that was missing from Collections (such as ArrayList). With generics, this is mitigated somewhat.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic