Error convert slice&push from P5.js to Processing

I want to convert Pong.js to Processing. I have two error:

int[] walls=new int[4]; //= [];
void wallAdder() {
  if (millis()-lastAddTime > wallInterval) {
    int randHeight = round(random(minGapHeight, maxGapHeight));
    int randY = round(random(0, height-randHeight));
    // {gapWallX, gapWallY, gapWallWidth, gapWallHeight, scored}
    int[] randWall={width, randY, wallWidth, randHeight, 0}; 
    walls.push(randWall); //here is error - Cannot invoke push(int[]) on the array int[]
    lastAddTime = millis();
void wallRemover(int index) {
  int[] wall =new int[walls[index]];
  if (wall[0]+wall[2] <= 0) {
    walls.splice(index, 1); //error - Cannot invoke push(int[]) on the array int[]

Help, pls!

1 Like

Java arrays don’t have any methods but only those inherited by the Object class:

Besides, Java arrays can’t have its length changed!

If you need a dynamic-sized container, you’re better off using an ArrayList instead:

1 Like