Java Number Format Pattern print(float[] array, NumberFormat nf)

Here you can find the source of print(float[] array, NumberFormat nf)

Description

Prints the contents of the float array on standard out.

License

Open Source License

Parameter

Parameter Description
array a parameter
nf the NumberFormat

Declaration

public static void print(float[] array, NumberFormat nf) 

Method Source Code


//package com.java2s;
/*/*from   w w  w. ja  va  2s  .  c om*/
 * Copyright (C) 2010-2014  Andreas Maier
 * CONRAD is developed as an Open Source project under the GNU General Public License (GPL).
*/

import java.text.NumberFormat;

public class Main {
    /**
     * Prints the contents of the float array on standard out.
     * @param array
     * @param nf the NumberFormat
     */
    public static void print(float[] array, NumberFormat nf) {
        System.out.print("[");
        for (int i = 0; i < array.length; i++) {
            System.out.print(" " + nf.format(array[i]));
        }
        System.out.println(" ]");
    }

    /**
     * Prints the array on standard out and denotes the arrays name.
     * @param name the name
     * @param array the array
     * @param nf the number format
     */
    public static void print(String name, float[] array, NumberFormat nf) {
        System.out.print(name + " = ");
        print(array, nf);
    }

    /**
     * Prints the array on standard out. Uses NumberFormat.getInstance() for number formatting
     * @param name the name 
     * @param array the array
     */
    public static void print(String name, float[] array) {
        print(name, array, NumberFormat.getInstance());
    }

    /**
     * Prints the array on standard out. Uses NumberFormat.getInstance() for number formatting
     * @param array the array
     */
    public static void print(float[] array) {
        print(array, NumberFormat.getInstance());
    }
}

Related

  1. isDecimalFormat(DecimalFormat decimalFormat)
  2. isDecimalFormatValid(final String pattern)
  3. matchOptionalFormatting(Number number, String formatting, StringBuffer outputTo)
  4. normalizeNumberFormat(NumberFormat numberFormat, int scale, int precision)
  5. objectToString(Object obj, DecimalFormat fmt)
  6. resetDecimalFormat()
  7. resetDecimalFormatByLocale(Locale locale)
  8. roundNumber(Number number, DecimalFormat format)
  9. stringFormat(BigDecimal value)