private static String toString(double[][] m,NumberFormat nf,List<String> variables){
  String result;
  if (nf == null) {
    throw new NullPointerException("NumberFormat must not be null.");
  }
  if (variables == null) {
    variables=new ArrayList<>();
    for (int i=0; i < m[0].length; i++) {
      variables.add("V" + (i + 1));
    }
  }
  if (m == null) {
    result=nullMessage();
  }
 else {
    TextTable textTable=new TextTable(m.length + 1,m[0].length);
    for (int i=0; i < variables.size(); i++) {
      textTable.setToken(0,i,variables.get(i));
    }
    for (int i=0; i < m.length; i++) {
      for (int j=0; j < m[0].length; j++) {
        textTable.setToken(i + 1,j,m[i][j] == 0 ? " " : nf.format(m[i][j]));
      }
    }
    result="\n" + textTable.toString();
  }
  return result;
}

private static String toString ( double [ ] [ ] m , NumberFormat nf , List < String > variables ) { String result ; if ( nf == null ) { throw new NullPointerException ( "NumberFormat must not be null." ) ; } if ( variables == null ) { variables = new ArrayList < > ( ) ; for ( int i = 0 ; i < m [ 0 ] . length ; i ++ ) { variables . add ( "V" + ( i + 1 ) ) ; } } if ( m == null ) { result = nullMessage ( ) ; } else { TextTable textTable = new TextTable ( m . length + 1 , m [ 0 ] . length ) ; for ( int i = 0 ; i < variables . size ( ) ; i ++ ) { textTable . setToken ( 0 , i , variables . get ( i ) ) ; } for ( int i = 0 ; i < m . length ; i ++ ) { for ( int j = 0 ; j < m [ 0 ] . length ; j ++ ) { textTable . setToken ( i + 1 , j , m [ i ] [ j ] == 0 ? " " : nf . format ( m [ i ] [ j ] ) ) ; } } result = "\n" + textTable . toString ( ) ; } return result ; }
copies the given array , using a standard scientific notation number formatter and beginning each line with the given lineinit . the number format is decimalformat ( " 0 . 0000 ; - 0 . 0000 " ) .
