Solved

one arraylist instead of many

Posted on 2004-04-14
13
207 Views
Last Modified: 2010-03-31
How could this be done.

I have 10 different sets of buttons with their actionCommands set to audiofiles. I have it set up now that each set of buttons have their own ArrayList that stores the order that the buttons are pressed.  How could one arraylist be able to store the order of all of the buttons from all of the sets. I could set it up to happen by the pressing of a special button.
0
Comment
Question by:Drop_of_Rain
  • 5
  • 4
  • 4
13 Comments
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10821218
You can keep arraylist of arraylist

or

you can even think of use HashMap, the key would be your group name and value would be the arraylist.


Regards,
Muruga
0
 
LVL 92

Expert Comment

by:objects
ID: 10821225
simply add the button to the single list whenever it is pressed, what exactly is the problem?
0
 
LVL 9

Assisted Solution

by:mmuruganandam
mmuruganandam earned 150 total points
ID: 10821245
If you need to add and maintain different collection then go ahead with the following....  Otherwise, you can add all buttons to a single list as objects suggested...



Meaning

Say group1, group2, group3.... is your keys

HashMap map = new HashMap();

ArrayList arrayList1 = new ArrayList();

addButtonsToArrayList(arrayList1);

map.put("group1", arrayList1);
.
.
.


This way you can maintain all the arraylist into a single map.

For getting the corresponding arraylist you can use the group name

ArrayList list = (ArrayList)map.get(groupName);


0
 

Author Comment

by:Drop_of_Rain
ID: 10821286
There is no problem. I want to be able to create a custom section in the program. In order to do this I will have to be able to keep track of each button press in an arraylist.

In answer to the hashmap this was the way I started to do it. If I need to do that I am OK with that.

There is no Group name, I didn't know that could be done. Well maybe there is a group name they all start with the same first letters kp1-kp50  and dm1-dm50 etc.
0
 
LVL 92

Expert Comment

by:objects
ID: 10821301
do u need to store what group each button is in?
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10821313
If you are clear about having different sections and keep track of those buttons in a arraylist, you can have groupname and start adding to the map.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Drop_of_Rain
ID: 10821322
No if I understand your question. That is taken care of by the audiofile name, but in this case it won't matter.
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10821332
Then go ahead with a single array list as you had before.
0
 
LVL 92

Accepted Solution

by:
objects earned 350 total points
ID: 10821347
> No if I understand your question. That is taken care of by the audiofile name, but in this case it won't matter.

then just uise a single arraylist and add all pressed buttons to it regardless of group.
0
 

Author Comment

by:Drop_of_Rain
ID: 10821362
If you are clear about having different sections and keep track of those buttons in a arraylist, you can have groupname and start adding to the map.

The group name would be the name of the Arraylist for each section.


simply add the button to the single list whenever it is pressed, what exactly is the problem?

I guess a single arrarlist could be set up to record all the buttons pressed each time and not use it except when the custom part is wanted.
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10821374
What is the problem now
0
 

Author Comment

by:Drop_of_Rain
ID: 10821430
Thanks again you guys,
Christopher
0
 
LVL 92

Expert Comment

by:objects
ID: 10821458
:)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java and GPO 11 66
Java - sorting a list of objects where the properties of the objects can change during the sort 7 47
javap bin 2 25
use lov values 2 18
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now