I have some problems with NPE, and i dont know how to fix it

i try to do a platformer, and i have problems with IntList
main code:

block[] b;
button[] bu;
player p;

IntList yB = new IntList();
IntList xB = new IntList();

int menu = 0;

void setup(){
  
  for(int i = 0; i < levelone.length; i++){
    for(int j = 0; j < levelone.length; j++){
      if(levelone[j][i] == 1){
        xB.append(0);
        yB.append(0);
      }
    }
  }
  print(xB, yB);
  
  rectMode(CENTER);
  size(400, 400);
  
  p.takeMap();
  p = new player(50, 50, 30, 80, 1);
  bu = new button[2];
  b = new block[32];
  
  bu[0] = new button(200, 200, 100, 50, "Start", -1);
  bu[1] = new button(340, 40, 100, 50, "back", 1);
}
void draw(){
  if(menu == 0){
    background(#FF8A15);
  }else if(menu == 1){
    background(200);
  }
  if(menu == 0){
    bu[0].show();
    bu[0].pressed();
  }
  
  if(menu == 1){
    bu[1].show();
    bu[1].pressed();
    for(int i = 0; i < 8; i++){
      for(int j = 0; j < 8; j++){
        for(int a = 0; a < 16; a++){
          if(levelone[j][i] == 1){
            b[a] = new block(i*50, j*50, 50, 50, 100, 50, 50);
            b[a].show();
          } 
        }
      }
    }
    p.moveButtons(50);
    p.show();
    p.move();
    p.coll();
    p.fall();
  }
  
  
}

and class code:

class player{
  boolean pressed = false;
  
  float x, y, Width, Height, fallSpeed;
  float b1x = 35, b1y = 365, b2x = 365, b2y = 365, b3x = 90, b3y = 365;
  
  void takeMap(){
    for(int i = 0; i < yB.size(); i++){
      for(int j = 0; j < xB.size(); j++){
        if(levelone[j][i] == 1){
          xB.add(j,j*50);
          yB.add(i,i*50);
        }
      }
    }
  }
  
  boolean downColl(){
    for(int i = 0; i < yB.size(); i ++){
      if(y >= yB.get(i)){
        return true;
      }
    }
    
    return false;
  }
  
  boolean mouseInside1(){
    if(mouseX >= b1x - 25 && mouseX <= b1x + 25 && mouseY >= b1y - 25 && mouseY <= b1y + 25){
      return true;  
    }
    return false;
  }
  boolean mouseInside2(){
    if(mouseX >= b2x - 25 && mouseX <= b2x + 25 && mouseY >= b2y - 25 && mouseY <= b2y + 25){
      return true;  
    }
    return false;
  }
  boolean mouseInside3(){
    if(mouseX >= b3x - 25 && mouseX <= b3x + 25 && mouseY >= b3y - 25 && mouseY <= b3y + 25){
      return true;  
    }
    return false;
  }
  
  player(float X, float Y, float w, float h, float fS){
    x = X;
    y = Y;
    Width = w;
    Height = h;
    fallSpeed = fS;
  }
  
  void show(){
    rectMode(CENTER);
    fill(#0006FF);
    rect(x, y, Width, Height);
    noFill();
  }
  
  void hitbox(){
    
  }
  
  void fall(){
    y += fallSpeed;
  }
  
  void moveButtons(float size){
    fill(0);
    //left button
    if(mouseInside1() && mousePressed){
      x-=1;
    }
    rect(b1x, b1y, size, size);
    //right button
    if(mouseInside2() && mousePressed){
      x+=1;
    }
    rect(b2x, b2y, size, size);
    //up
    if(mouseInside3() && mousePressed){
      if(pressed == false){
        y-=70;
        pressed = true;
      }
    }
    if(downColl()){
      pressed = false;
    }
    rect(b3x, b3y, size, size);
    noFill();
  }
  
  void move(){
    
  }
  
  void coll(){
    if(downColl()){
      fallSpeed = 0;
    }else{
      fallSpeed = 1;
    }
    
  }
  
}

i dont know how to fix. Problem in p.takeMap();
thanks in advance

I don’t think you can use yB.size() as upper bound for the for loop. It might be bigger
than levelone.length