Creating an array of arrays


#1

First time using Processing. Trying to make a temporary graphical interface for my Arduino project. Probably super simple question.
How do I go about creating an array of arrays, then accessing the individual subelements?

I have a basic array myArray[] = {0,0,0,0,0};
I want to be able to make more arrays of various sizes with myArray as the element.
myArray[] firstArray = new myArray[3];
myArray[] secondArray = new myArray[5];

firstArray[0][0] = 100;
secondArray[1][2] = 37;

etc.


#2

Made it an array of a class. That seems to do what I needed.


class theClass
{
  int a,b,c,d,e;
}

theClass[] firstArray = theClass[3];
theClass[] secondArray = theClass[5];

setup()
{
  firstArray[0].a = 100;
  secondArray[1].b = 37;
}

#3

int[][] 2d array example: :nerd_face:


Processing.org/examples/array2d.html


#4

Some more 2D array sketches: :innocent:

Studio.ProcessingTogether.com/sp/pad/export/ro.9ABG0RKl9D2Bx

Studio.ProcessingTogether.com/sp/pad/export/ro.9WgKFjA6WFscW


#5

Thanks. Must be too early in the morning here.
I’ve been making multi-dimensional arrays like that for ever. Don’t know why I got tripped up.