We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Multidimensional Arraylist
Page Index Toggle Pages: 1
Multidimensional Arraylist (Read 338 times)
Multidimensional Arraylist
Mar 5th, 2009, 4:49pm
 
I'm making a drawing program, storing location vectors in an Arraylist.  I would like to abstract that further by placing these ALists inside of another.  For example: Words is an ArrayList of Letters, which in turn is an Arraylist of points which make 1 letter.  I think it is possible to create this structure, but how to access the methods of the nested ALists?
Re: Multidimensional Arraylist
Reply #1 - Mar 5th, 2009, 5:07pm
 
You have to do cascaded gets:

Word w = (Word) words.get(n);
Letter l = (Letter) w.get(0);

etc.
Re: Multidimensional Arraylist
Reply #2 - Mar 5th, 2009, 6:40pm
 
Okay, I think that makes sense.  Do I need to declare word and letter?  How can I declare a letter within a word?

word.add(letter = new ArrayList());

Also, how to add vectors to letter?

Page Index Toggle Pages: 1