public String toString(){
  StringBuffer sb=new StringBuffer();
  boolean firstNonZeroCoefficientPrinted=false;
  for (int n=0; n < coefficients.length; n++) {
    if (coefficients[n] != 0) {
      if (firstNonZeroCoefficientPrinted)       sb.append(coefficients[n] > 0 ? " + " : " ");
 else       firstNonZeroCoefficientPrinted=true;
      if (n == 0 || coefficients[n] != 1)       sb.append(Double.toString(coefficients[n]));
      if (n > 0)       sb.append(" X^" + n);
    }
  }
  return sb.toString();
}

public String toString ( ) { StringBuffer sb = new StringBuffer ( ) ; boolean firstNonZeroCoefficientPrinted = false ; for ( int n = 0 ; n < coefficients . length ; n ++ ) { if ( coefficients [ n ] != 0 ) { if ( firstNonZeroCoefficientPrinted ) sb . append ( coefficients [ n ] > 0 ? " + " : " " ) ; else firstNonZeroCoefficientPrinted = true ; if ( n == 0 || coefficients [ n ] != 1 ) sb . append ( Double . toString ( coefficients [ n ] ) ) ; if ( n > 0 ) sb . append ( " X^" + n ) ; } } return sb . toString ( ) ; }
returns a string representing the receiver
