Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

arraylist

 
Yuvaraj Deena
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15288
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Cooke
Sheriff
Pie
Posts: 2980
123
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic