• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Type Collection

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was wondering, how does type collection work? If Im wanting a list of files returned as a collection, how would I do it?
 
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Collection

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 ]
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)

Layne
 
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic