code: public double[] toArray(double[] a) {
          if (response == null) {
              throw new IllegalArgumentException("The dataset has no response values.");            
          }
          
          if (response.getType() != Attribute.Type.NUMERIC) {
              throw new IllegalArgumentException("The response variable is not numeric.");
          }
          
          int m = data.size();
          if (a.length < m) {
              a = new double[m];
          }
          
          for (int i = 0; i < m; i++) {
              a[i] = get(i).y;
          }
          
          for (int i = m; i < a.length; i++) {
              a[i] = Double.NaN;
          }
          
          return a;
      }
docs: Returns an array containing the response variable of the elements in this
  dataset in proper sequence (from first to last element). If the dataset
  fits in the specified array, it is returned therein. Otherwise, a new array
  is allocated with the size of this dataset.
  <p>
  If the dataset fits in the specified array with room to spare (i.e., the
  array has more elements than the dataset), the element in the array
  immediately following the end of the dataset is set to Double.NaN.
  
  @param a the array into which the response variable of this dataset are
  to be stored, if it is big enough; otherwise, a new array is allocated
  for this purpose.
  @return an array containing the response variable of this dataset.