title: How to add data in array on button click?
body: <pre><code>    int size = mcq.size();
  
  
      String arr[] = null;
      int i;
      {
  
  
          for (i = 0; i &lt; size; i++) {
  
  
              if (op1.isPressed()) {
                  arr[i] = tv1.getText().toString();
                  // Log.e("Array",arr[i]);
  
              } else if (op2.isPressed()) {
                  arr[i] = tv2.getText().toString();
                  //Log.e("Array",arr[i]);
  
              } else if (op3.isPressed()) {
                  arr[i] = tv3.getText().toString();
                  //  Log.e("Array",arr[i]);
  
  
              } else if (op4.isPressed()) {
                  arr[i] = tv4.getText().toString();
                  //Log.e("Array",arr[i]);
  
  
              }
  </code></pre>
  
  <p>I am trying to store the data in an array when the button is pressed,but it always shows null.And when the for loop is over I want to display my array.</p>