aspose file tools*
The moose likes Beginning Java and the fly likes arraylist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "arraylist" Watch "arraylist" New topic
Author

arraylist

Yuvaraj Deena
Greenhorn

Joined: Aug 24, 2013
Posts: 8
Hi,

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?

Thanks,
yuva
Ahsan Bagwan
Ranch Hand

Joined: Oct 05, 2010
Posts: 161
ArrayList is a concrete implementation of the List interface. Think of a list as an Object array where you can dynamically add or remove elements.

But first, ask yourself why you need a List. Only then you need to zero in on an ArrayList (or LinkedList or any other class for that matter).

The fine details of the differences are in the API docs where it points out things like -- duplicate elements and nulls allowed, and all that.

And about the differences in Java 4 and 5, I'm not sure but I think there might not be any major changes.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14273
    
  21

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Tim Cooke
Bartender

Joined: Mar 28, 2008
Posts: 1132
    
  59

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).


Tim Driven Development
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: arraylist