Java Float Array to String floatArrayToString(final float[] floatArray)

Here you can find the source of floatArrayToString(final float[] floatArray)

Description

Returns a string representation of the given float array.

License

Open Source License

Parameter

Parameter Description
floatArray the given float array

Return

a string representation of the given float array

Declaration

public static String floatArrayToString(final float[] floatArray) 

Method Source Code

//package com.java2s;
/*/*ww w  .  java2s  .  co m*/
 * StringUtils.java
 *
 * Created on October 4, 2006, 2:36 PM
 *
 * Description:
 *
 * Copyright (C) 2006 Stephen L. Reed.
 *
 * 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 2 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

public class Main {
    /** Returns a string representation of the given float array.
     *
     * @param floatArray the given float array
     * @return a string representation of the given float array
     */
    public static String floatArrayToString(final float[] floatArray) {
        final StringBuilder stringBuilder = new StringBuilder();
        boolean isFirst = true;
        stringBuilder.append('[');
        for (int i = 0; i < floatArray.length; i++) {
            if (isFirst) {
                isFirst = false;
            } else {
                stringBuilder.append(", ");
            }
            stringBuilder.append(floatArray[i]);
        }
        stringBuilder.append(']');

        return stringBuilder.toString();
    }
}

Related

  1. floatArrayToString(float[] array)
  2. floatArrayToString(String tag, float[] arr)
  3. floats2strs(float[] fs)