# 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:** 2\
**Page:** 3

<div class="post-metadata">

**Author:** ![Yoha](https://avatars.discourse-cdn.com/v4/letter/y/a4c791/32.png) [@Yoha](https://discourse.processing.org/u/Yoha)\
**Post date:** [March 19, 2023, 12:54pm UTC](https://discourse.processing.org/t/arraylist-of-arraylists-dynamic-2d-array-of-custom-class/27923/41 "2023-03-19T12:54:09Z")

</div>

Hey Chrisir  
any reference material on how to use arraylists within objects ?  
Thanks

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 19, 2023, 2:35pm UTC](https://discourse.processing.org/t/arraylist-of-arraylists-dynamic-2d-array-of-custom-class/27923/42 "2023-03-19T14:35:19Z")

</div>

your question is very broad, but you can treat an ArrayList within a class just normal:

come back for more questions please 😉

```auto

Circle myCircle = new Circle(); // make object from class 

void setup() {
  size(800, 800);
}// function setup()

void draw() {
  background(0);
  myCircle.display(); // use method in the class 

  noFill();
  stroke(255);
  // use ArrayList in the class (not so nice)
  rect(myCircle.points.get(2).x, myCircle.points.get(2).y,
    30, 30);
  //
}// function draw()

// =====================================================================================

class Circle {

  ArrayList<PVector> points = new ArrayList();

  // constr
  Circle () {
    points.add(new PVector(123, 234));
    points.add(new PVector(143, 334));
    points.add(new PVector(223, 434));
  }// constr

  void display() {
    fill(255);
    for (PVector pv : points) {
      ellipse(pv.x, pv.y, 12, 12);
    } // for
  }//method
  //
}//class
//

```

[Previous page](https://discourse.processing.org/t/arraylist-of-arraylists-dynamic-2d-array-of-custom-class/27923.md?page=2)
