# ArrayList of ArrayLists (dynamic 2D array) of custom class

**URL:** <https://discourse.processing.org/t/arraylist-of-arraylists-dynamic-2d-array-of-custom-class/27923>\
**Category:** Beginners\
**Created:** [February 19, 2021, 6:26am UTC](https://discourse.processing.org/t/arraylist-of-arraylists-dynamic-2d-array-of-custom-class/27923 "2021-02-19T06:26:32Z")\
**Posts on this page:** 1\
**Showing post:** 23

<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:** [February 20, 2021, 12:10am UTC](https://discourse.processing.org/t/arraylist-of-arraylists-dynamic-2d-array-of-custom-class/27923/23 "2021-02-20T00:10:37Z")

</div>

> [@ProgrammingN00b](#):
>
> (I can see now why some people have a “distaste” for Java …)

If how reference behaves under Java was the reason why Java isn’t liked much folks would also hate JavaScript, Python and almost all modern programming languages! 😳

Actually programmers tend to dislike Java b/c we have to explicitly declare the datatype of each single variable just like old C/C++ do! 😱

BtW I’ve got some previous posts about Java’s reference aliases below: ☕

> [@Boolean trouble or something](https://discourse.processing.org/t/boolean-trouble-or-something/16217/5):
>
> Variables/fields/parameters store a single value. They range from 1 byte to 8 bytes in most languages. At the statement m = new PVector(); the operator new creates a contiguous memory block enough to fit in all PVector’s non-static fields. And when it’s done, it returns the 1st memory address of that block. And finally, that 1st memory address is stored in the field m as a reference value. Now, when you do pressLoc = m, you’re assigning field pressLoc w/ the exact value of m. After that assign…

> [@Final array is being changed](https://discourse.processing.org/t/final-array-is-being-changed/1447/4):
>
> Some of my clone() examples I did a long time ago at the link below may help ya out: smile_cat[https://Forum.Processing.org/two/discussion/12044/how-do-i-copy-out-one-row-of-a-2d-array-into-a-1d-array](https://Forum.Processing.org/two/discussion/12044/how-do-i-copy-out-one-row-of-a-2d-array-into-a-1d-array) final int[][] stuff = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }; final int[] myArray = stuff[2]; // it's an alias for stuff[2]. myArray[0] = 10; // thus it alters stuff[2] too! println(stuff[2][0]); // prints out 10. stuff[2] is also affected! final int[] myClone = stuff[2].clone(); // it's a clon…

> [@Final array is being changed](https://discourse.processing.org/t/final-array-is-being-changed/1447/6):
>
> The 1st example explains at its comments why the 2nd 1 works. wink Processing got nothing to do w/ that, but the Java language itself! coffee As you know by now, the 1st example already got those basic insights. roll_eyes Basically, we can have more than 1 variable (and array slots) pointing at the same object. They simply become alias for the same object. flushed That is, if we mutate an object via 1 of its alias, its other aliases see those changes as well, b/c they all store th…

> [@How do I pass a function by reference and then call it?](https://discourse.processing.org/t/how-do-i-pass-a-function-by-reference-and-then-call-it/27474/3):
>
> Actually JS functions, just like Java’s, are ALWAYS pass by value, regardless it’s a primitive or object datatype. When we pass a variable as a single argument to a function, the current value stored in that variable is read, and then the invoked function’s receiving parameter is initialized w/ a copy of that read value. B/c a function’s parameter can only receive a copy of the current value stored in a passed variable, reassigning another value to that local parameter won’t replace the value…

---

_[View the full topic](https://discourse.processing.org/t/arraylist-of-arraylists-dynamic-2d-array-of-custom-class/27923)._
