File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Type Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Type Collection" Watch "Type Collection" New topic

Type Collection

Alan Jackson

Joined: Oct 26, 2004
Posts: 26
I was wondering, how does type collection work? If Im wanting a list of files returned as a collection, how would I do it?
Nick George
Ranch Hand

Joined: Apr 04, 2004
Posts: 815

If you'd like a more specific answer, ask a more specific question. Anytime you return a List, you are returning a Collection, as List implements Collection.
[ November 11, 2004: Message edited by: Nick George ]

I've heard it takes forever to grow a woman from the ground
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I think most introductory Java texts dedicate at least a whole chapter to the Collections framework. This should give you an idea of how broad the topic is. The link Nick gave to the API docs is good for reference, but probably doesn't help you understand how to use it. As Nick mentioned, you need to be more specific about which type of Collection you want to use. In this case, List sounds appropriate. Now you need to decide, what type of List to use. There are basically two kinds of lists: linear and random access. If you only need to access the elements in order, a linear LinkedList is appropriate. However, a random access list is more popular since it is more like an array (i.e. you can efficiently access any element by a given index). In this case, you can use either ArrayList or Vector. ArrayList is the usual choice. The major difference is that Vector is designed to be thread safe. So unless you are writing a threaded program, you should avoid the overhead in Vector and just use ArrayList instead.

Well, this is only a general overview. Please feel free to ask more specific questions that pertain to your particular problem.

Keep Coding! (TM)


Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: Type Collection
It's not a secret anymore!