code: public int[] toArray(int[] a) {
          if (response == null) {
              throw new IllegalArgumentException("The dataset has no response values.");            
          }
          
          if (response.getType() != Attribute.Type.NOMINAL) {
              throw new IllegalArgumentException("The response variable is not nominal.");
          }
          
          int m = data.size();
          if (a.length < m) {
              a = new int[m];
          }
          
          for (int i = 0; i < m; i++) {
              Datum<SparseArray> datum = get(i);
              if (Double.isNaN(datum.y)) {
                  a[i] = Integer.MIN_VALUE;
              } else {
                  a[i] = (int) get(i).y;
              }
          }
          
          for (int i = m; i < a.length; i++) {
              a[i] = Integer.MIN_VALUE;
          }
          
          return a;
      }
docs: Returns an array containing the class labels of the elements in this
  dataset in proper sequence (from first to last element). Unknown labels
  will be saved as Integer.MIN_VALUE. 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 Integer.MIN_VALUE.
  
  @param a the array into which the class labels 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 class labels of this dataset.