Java Decimal Format printArray(String title, double[] vect)

Here you can find the source of printArray(String title, double[] vect)

Description

print Array

License

Open Source License

Declaration

public static String printArray(String title, double[] vect) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.DecimalFormat;

public class Main {
    private static DecimalFormat decimalFormat;

    public static String printArray(String title, double[] vect) {
        String result = title + ": ";
        result += arrayToString(vect);//  w w  w.  ja v  a2 s . co m
        result += "\n";
        return result;
    }

    public static String printArray(Object[] array, String separator) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < array.length; i++) {
            builder.append(array[i]);
            if (i < array.length + 1)
                builder.append(separator);
        }
        return builder.toString();
    }

    public static String arrayToString(double[] vect) {
        String result = "";
        for (int j = 0; j < vect.length; j++) {
            result += formatDouble(vect[j]);
            if (j + 1 < vect.length)
                result += " ";
        }
        return result;
    }

    public static String formatDouble(double d) {
        return decimalFormat.format(d);
    }
}

Related

  1. padToMinWidth(double num, int minWidth)
  2. prettyPrintLatLon(double coord, boolean isCoordKindLat)
  3. print(double[] y)
  4. printAlpha(double a[])
  5. printAngle(double angle)
  6. printArrayP(double[][] p)
  7. PrintWith1DecAnd000Sep(double Number)
  8. randomDouble(double minDouble, double maxDouble)
  9. randomGenLat(Double latstart, Double latend)