Can anyone please tell me. when a programmer will have use arraylist during application development ?. In which situation they prefer arraylist ?..any difference occurs in arraylist between java version 5 and java version 4?
It happens very often in programs that you need to work with collections of objects, and a list is probably the most common collection. Java has an interface java.util.List and several standard implementations of this interface. java.util.ArrayList is probably the most commonly used List implementation in Java.
The biggest difference between Java 4 and Java 5 with regard to ArrayList (and other collection classes) is the introduction of generics in Java 5.
This sounds a little bit like an interview or homework question, albeit a somewhat outdated question as Java 5 was released 9 years ago. At The Ranch we encourage folks to DoYourOwnHomework (<-- click) and ShowSomeEffort (<-- click). So to that end, when do you think you might want to use an ArrayList? Preferable to what?
Ahsan Bagwan wrote:And about the differences in Java 4 and 5, I'm not sure but I think there might not be any major changes.
I'll give you a freebee here as Ahsan's post may mislead you a little. The significant difference between Java 4 and 5 that affected the Collection interface was Generics (<-- Oracle tutorial).