As JAVA leaders I need your advice on choosing the best Collection (HashTable, HashMap,,,etc.) that is uitable for me. I need it to enables me sotre and access: 1) Object 2) Two boolean values 3) An index Like follow:
index Object boolean1 boolean2 ----- ------ -------- --------
Probably it depends on how you would be accessing the data..
1. If you want to access the data with the help of a key lets say the index value here you can put the index as key and the rest values clubbed in a object as a value object in either HashMap or HashTable. The difference between HashMap and HashTable is that HashTable is synchronized where as HashMap is not.
2. If you do not think you would be accessing the data by key you can put it in an Arraylist as Satou mentioned above.
medRat
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
posted
0
That was a good suggestion to put your several data elements into a little class and store objects of that class in your collection. Here is a collection crib sheet I made because I couldn't keep them all in my head. There are more that this but these are the common ones.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
posted
0
Originally posted by KJ Reddy: I am not sure if you have that facility in Collectio classes. But why can not you store boolean1 & boolean2 values in the same object.
I am not sure where you are coming from here. You certainly CAN store two boolean variables in the same object:
As JAVA leaders I need your advice on choosing the best Collection (HashTable, HashMap,,,etc.) that is uitable for me. I need it to enables me sotre and access: 1) Object 2) Two boolean values 3) An index Like follow:
index Object boolean1 boolean2 ----- ------ -------- --------
Best Regards,
This only describes WHAT data you need to store. In order to decide which Collection to use, you also need to consider HOW you want to store and access this data. Perhaps it will help if you describe what this data represents. Feel free to use this forum as a sounding board. There are plenty of people here that will pipe in with suggestions.
Layne
Bashar Ayyash
Ranch Hand
Joined: Jun 24, 2004
Posts: 44
posted
0
Guys I want to say one word, THANK YOU FROM ALL MY HEART, I can't express my thankfull to you. You are giving the true meaning of the net, this is the purpose beyond creating the net to (Share) knowledge. Also, one of the main things that made me choose Open Source Technology (JAVA) is this.
Thank you again.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.