# How do nested arrays such as IntDict\[\] work? (Processing 3.5.4)

**URL:** <https://discourse.processing.org/t/how-do-nested-arrays-such-as-intdict-work-processing-3-5-4/26818>\
**Category:** Beginners\
**Created:** [January 6, 2021, 4:08am UTC](https://discourse.processing.org/t/how-do-nested-arrays-such-as-intdict-work-processing-3-5-4/26818 "2021-01-06T04:08:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anon0908](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@Anon0908](https://discourse.processing.org/u/Anon0908)\
**Post date:** [January 6, 2021, 4:08am UTC](https://discourse.processing.org/t/how-do-nested-arrays-such-as-intdict-work-processing-3-5-4/26818/1 "2021-01-06T04:08:54Z")

</div>

How do I properly invoke array commands such as `append()` on an `IntDict[]` array? For example, this is my current sketch testing such a thing:

```auto
IntDict[] dictArray;
void setup() {
  size(1400, 1000);
  /*properly initialized or not?*/
  dictArray = new IntDict[2];
  append(dictArray, new IntDict());
  /*when the compiler stops*/
  dictArray[1].set("dictVar", 0);
}

void draw() {
  println(dictArray[1].get("dictVar"));
}

```

The error the console gives me is ‘NullPointerException.’ The sketch window is unresponsive. How do I rewrite the above code?

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [January 6, 2021, 7:05am UTC](https://discourse.processing.org/t/how-do-nested-arrays-such-as-intdict-work-processing-3-5-4/26818/2 "2021-01-06T07:05:03Z")

</div>

> [@Anon0908](#):
>
> How do I properly invoke array commands such as **append()** on an IntDict[] array?

[Why use ArrayList instead of array with append()? - Processing 2.x and 3.x Forum](http://forum.Processing.org/two/discussion/8080/why-use-arraylist-instead-of-array-with-append)

> **[append() / Reference](https://processing.org/reference/append_.html)**
>
> Expands an array by one element and adds data to the new position. The datatype of the element parameter must be the same as the datatype of the array. When using an array of object…

> [@Anon0908](#):
>
> How do I rewrite the above code?

```auto
static final int ROWS = 2;
final IntDict[] dictArray = new IntDict[ROWS];

void setup() {
  for (int i = 0; i < ROWS; dictArray[i++] = new IntDict());
  dictArray[1].set("dictVar", 0);
  println(dictArray[1].get("dictVar")); // 0
  exit();
}

```
