hi all! can someone tell me when i should use Arrays and when should i use collection classes to store different type of refrences (objects) madhur.
Joined: Aug 05, 2002
The arrays and collection have their own pro and cons. You have outline your requirement in terms of these pros and cons, then the choice becomes very easy. One thing to remember is that there is no absolute anser such as "always use arrays.."
Joined: Jul 03, 2001
The main reason to use collections is that their size isn't fixed as with arrays. Another advantages are that some containers have some useful behaviour built-in. It would be possible to simulate it with arrays, but it's already there for us. a) when you need an associative array use some kind of Map. b)you need some set operations? use some kind of Set c) you need a stack ? use a LinkedList