posted 16 years ago
1. Without casting, you will only be able to call methods from the Collection interface on the object that xList references. So even though xList refers to an ArrayList instance, you would not be able to call the indexOf method for example. The advantage of declaring it this way is that it makes it easy to replace the ArrayList with any other object that implements the Collection interface.
2. Same as 1 except replace Collection with List and indexOf with some method that is not in the List interface (e.g. trimToSize)
3. This allows you to use all of ArrayList's methods, but could cause problems if you decide you want to use some other type of List/Collection in future.