arrayList, argument to .add.
in
Programming Questions
•
2 years ago
Hi all. Hoping somebody here can help me with a Processing problem.
I am adding elements to an arrayList when two strings are identical to one another using the code below.
- for(int i = 0; i < postcodesArray.length; i++) {
- for(int i2 = 0; i2 < allPostcodes.length; i2++) {
- if(postcodesArray[i].equals(allPostcodes[i2])) {
- N1.add(new Particle());
- }
- }
- }
What I want however is multiple arrayLists, and each time the strings are identical, to extract the string at that point in the array, and use this string as an argument to the add method. So I would have say 3 arrayLists - N1, N2, N3 - and if the matching string was N3, it would add to the N3 arrayList and so forth. I hope this is clear. I plan to have 100 or so arrayLists, so using if statements to check each string seemed a bit too long of a solution.
Any help is much appreciated as always.
Thanks in advance.
Andy.
1