I want to save data into an array using the for function. the following script is used:

```
int[] U;
int k = 0;

String ukecil = i.getStringExtra("ukecil");
String ubesar = i.getStringExtra("ubesar");

int ukk = Integer.parseInt(ukecil);
int ukb = Integer.parseInt(ubesar);

for (int j=ukk; j<=ukb; j++){
  U[k]= j;
  k++;
}

tx_uk1.setText(U[0]);
tx_uk2.setText(U[1]);
tx_uk3.setText(U[2]);

```

then I want to display data in text view.
but there is an error which is:

```
java.lang.NullPointerException: Attempt to write to null array

```

this section error:

```
U[k]= j;

```