Java Array Output printArray(float[] arr)

Here you can find the source of printArray(float[] arr)

Description

Prints out the array to standard output.

License

Open Source License

Parameter

Parameter Description
arr An array of float values.

Declaration

public static void printArray(float[] arr) 

Method Source Code

//package com.java2s;
/**/*from w w  w. ja  v  a 2s .  c o  m*/
 * Hub Miner: a hubness-aware machine learning experimentation library.
 * Copyright (C) 2014  Nenad Tomasev. Email: nenad.tomasev at gmail.com
 * 
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Prints out the array to standard output.
     *
     * @param arr An array of float values.
     */
    public static void printArray(float[] arr) {
        if (arr == null) {
            System.out.println("Null array.");
            return;
        }
        for (int i = 0; i < arr.length - 1; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.print(arr[arr.length - 1]);
        System.out.println();
    }

    /**
     * Prints out the array to standard output.
     *
     * @param arr An array of integer values.
     */
    public static void printArray(int[] arr) {
        if (arr == null) {
            System.out.println("Null array.");
            return;
        }
        for (int i = 0; i < arr.length - 1; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.print(arr[arr.length - 1]);
        System.out.println();
    }

    /**
     * Prints out the array to standard output.
     *
     * @param arr An array of double values.
     */
    public static void printArray(double[] arr) {
        if (arr == null) {
            System.out.println("Null array.");
            return;
        }
        for (int i = 0; i < arr.length - 1; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.print(arr[arr.length - 1]);
        System.out.println();
    }

    /**
     * Prints out the array to standard output.
     *
     * @param arr An array of string values.
     */
    public static void printArray(String[] arr) {
        if (arr == null) {
            System.out.println("Null array.");
            return;
        }
        for (int i = 0; i < arr.length - 1; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.print(arr[arr.length - 1]);
        System.out.println();
    }
}

Related

  1. printArray(double[] array, String msgBefore, String msgAfter)
  2. printArray(double[][] in)
  3. printArray(double[][] in)
  4. printarray(final int[] a)
  5. printArray(final Object[] array, int indent)
  6. printArray(int arr[])
  7. printArray(int[] arr)
  8. printArray(int[] array)
  9. printArray(int[][] array, String arrayLabel, String rowLabel, String columnLabel)