I tried to get a array from an adapter from my code

here is the array that i wanted to get from my adapter, named MakananAdapter :

```
private int[] JumlahPesan = {0,0,0,0};

```

The array is changing constantly since user will be deciding the amount that they want, here is the onBindViewHolder code:

```
public void onBindViewHolder(@NonNull viewHolder holder, final int position) {
    ImageView ivMakanan = holder.ivMakanan;
    TextView tvNamaHarga = holder.tvNamaMakanan;
    TextView tvKetersediaan = holder.tvKetersediaan;
    TextView tvHarga = holder.tvHargaMakanan;
    final TextView tvPesanan = holder.tvJumlahPesanan;
    Button btnTambah = holder.btnTambah;
    Button btnKurang = holder.btnKurang;

    ivMakanan.setImageResource(makanans.get(position).getGambarMakanan());
    tvNamaHarga.setText(makanans.get(position).getNamaMakanan());
    tvKetersediaan.setText("Stok : " + makanans.get(position).getStatusMakanan());
    tvHarga.setText("Harga : " + makanans.get(position).getHargaMakanan());
    btnTambah.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            JumlahPesan[position]++;
            tvPesanan.setText(String.valueOf(JumlahPesan[position]));
        }
    });
    btnKurang.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            JumlahPesan[position]--;
            tvPesanan.setText(String.valueOf(JumlahPesan[position]));
        }
    });
}

```

as you can see i make a button that increase and decrease the data of the array

and i tried to get the array data to my activity, but i still get error.

my activity named PilihMakananActivity.class

here is the array to save the data from the adapter

```
private int[] Pesanan = {0,0,0,0};

```

and i tried to get the data in onResume

```
protected void onResume() {
    super.onResume();
    com.example.iotforcanteen.adapter.MakananAdapter coba = null;
    for (int i = 0; i<4 ; i++) {
        Pesanan [i]= coba.AmbilJumlahPesanan(i);
    }
}

```

and i tried to show it in a snackbar like this

```
btnKonfirmasi.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Snackbar.make(v, Pesanan[0] + Pesanan[1] + Pesanan[2] + Pesanan[3],Snackbar.LENGTH_SHORT).show();
    }
});

```

Im so sorry if the code is so messy, because im new to android development.so is there any way to fix this error?