angeles (
[email protected]) wrote:
: For example, I have multiple sets of following data need to be stored:
: date1, time1, month1, year1
: date2, time2, month2, year2
In a language like C, a set of items (date1, time1, month1, year1) would
be stored in a structure.
In Java, instead of a structure, each set of related items would typically
be stored as the instance variables of an object, in a class defined for
this purpose. In the above example you show two sets of related things,
set 1, and set 2. This would require two objects.
: ....
: Which of following data type should be used: Collection, Array, :
ArrayList, List? or others?
You should then use what ever kind of grouping will provide the access you
require with the minimum amount programming effort on your part. If you
must simply examine each object in order then an array would suffice. If
you need to access individual objects based on a key, and perhaps add and
remove items from time to time, then something else would be best.
I suggest you sketch out the code you think you will need on a piece of
paper ahead of time, and write outlines of the routines you will need
using several of the choices, and see which one will do what you want most
easily when you use it.
: then how to extract the data from collections?
I don't remember, I would look it up in my handy dandy java reference
book.