# How do I make an array larger?

**URL:** <https://discourse.processing.org/t/how-do-i-make-an-array-larger/42361>\
**Category:** Beginners\
**Created:** [July 6, 2023, 11:13pm UTC](https://discourse.processing.org/t/how-do-i-make-an-array-larger/42361 "2023-07-06T23:13:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nuhuhwy](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/nuhuhwy/32/18485_2.png) [@nuhuhwy](https://discourse.processing.org/u/nuhuhwy)\
**Post date:** [July 6, 2023, 11:13pm UTC](https://discourse.processing.org/t/how-do-i-make-an-array-larger/42361/1 "2023-07-06T23:13:05Z")

</div>

I am trying to make a array, that if you get to the end, it gets one larger.  
this is my code:

```auto
String[] text = new String[32];

int scroll;
int visScroll;
float scrollSpeed;

int lineHeight = 24;

void setup() {
  size(324, 522);
  textSize(14);

  for (int i = 0; i < 32; i++) {
    text[i] = i+"1";
  }
}

void draw() {
background(0);
  handleScrolling();
  for (int i = 0; i < height/lineHeight+2; i++) {
      try {
        fill(255);
        text(text[i-scroll], 10, visScroll+i*lineHeight+22);
      }
      catch (Exception E) {
        text = (String[]) expand(text);
      }
    }
}

void handleScrolling() {
  if (mousePressed) scrollSpeed = pmouseY-mouseY;
  visScroll -= scrollSpeed;
  scrollSpeed -= scrollSpeed/6;
  if (visScroll > lineHeight) {
    scroll++;
    visScroll = 0;
  }
  if (visScroll < -lineHeight) {
    scroll--;
    visScroll = 0;
  }
}

```

---

<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:** [July 6, 2023, 11:46pm UTC](https://discourse.processing.org/t/how-do-i-make-an-array-larger/42361/2 "2023-07-06T23:46:08Z")

</div>

[Forum.Processing.org/two/discussion/8080/why-use-arraylist-instead-of-array-with-append.html](https://forum.processing.org/two/discussion/8080/why-use-arraylist-instead-of-array-with-append.html)
