Java Array arrayStr(int[] A)

Here you can find the source of arrayStr(int[] A)

Description

Converts an array to a human-readable string, for debugging purposes.

License

Open Source License

Declaration

public static String arrayStr(int[] A) 

Method Source Code

//package com.java2s;
/*//from   ww  w.  j av a  2 s .c om
 * BioAssay Ontology Annotator Tools
 * 
 * (c) 2014-2016 Collaborative Drug Discovery Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License 2.0
 * as published by the Free Software Foundation:
 * 
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
 * 
 * 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */

public class Main {
    /**
     * Converts an array to a human-readable string, for debugging purposes.
     */
    public static String arrayStr(int[] A) {
        if (A == null)
            return "{null}";
        String str = "";
        for (int n = 0; n < A.length; n++)
            str += (n > 0 ? "," : "") + A[n];
        return str;
    }

    /**
     * Converts an array to a human-readable string, for debugging purposes.
     */
    public static String arrayStr(long[] A) {
        if (A == null)
            return "{null}";
        String str = "";
        for (int n = 0; n < A.length; n++)
            str += (n > 0 ? "," : "") + A[n];
        return str;
    }

    /**
     * Converts an array to a human-readable string, for debugging purposes.
     */
    public static String arrayStr(float[] A) {
        if (A == null)
            return "{null}";
        String str = "";
        for (int n = 0; n < A.length; n++)
            str += (n > 0 ? "," : "") + A[n];
        return str;
    }

    /**
     * Converts an array to a human-readable string, for debugging purposes.
     */
    public static String arrayStr(double[] A) {
        if (A == null)
            return "{null}";
        String str = "";
        for (int n = 0; n < A.length; n++)
            str += (n > 0 ? "," : "") + A[n];
        return str;
    }

    /**
     * Converts an array to a human-readable string, for debugging purposes.
     */
    public static String arrayStr(String[] A) {
        if (A == null)
            return "{null}";
        String str = "";
        for (int n = 0; n < A.length; n++)
            str += (n > 0 ? "," : "") + "\"" + A[n] + "\"";
        return str;
    }

    /**
     * Converts an array to a human-readable string, for debugging purposes.
     */
    public static String arrayStr(boolean[] A) {
        if (A == null)
            return "{null}";
        String str = "{";
        for (int n = 0; n < A.length; n++)
            str += (A[n] ? "1" : "0");
        return str + "}";
    }

    /**
     * Converts an array to a human-readable string, after having applied a multiplier.
     * @param A array to format
     * @param mul modifier to multiply by
     */
    public static String arrayStr(float[] A, float mul) {
        String str = "";
        for (int n = 0; n < A.length; n++)
            str += (n > 0 ? "," : "") + (A[n] * mul);
        return str;
    }

    /**
     * Converts an array to a human-readable string, after having applied a multiplier.
     * @param A array to format
     * @param mul modifier to multiply by
     */
    public static String arrayStr(double[] A, double mul) {
        String str = "";
        for (int n = 0; n < A.length; n++)
            str += (n > 0 ? "," : "") + (A[n] * mul);
        return str;
    }

    /**
     * Converts an array to a human-readable string, for debugging purposes.
     */
    public static String arrayStr(int[][] A) {
        if (A == null)
            return "{null}";
        String str = "";
        for (int n = 0; n < A.length; n++)
            str += A[n] == null ? "{null}" : "{" + arrayStr(A[n]) + "}";
        return str;
    }
}

Related

  1. arrayRangeEquals(byte[] a, int aOffset, byte[] b, int bOffset, int byteCount)
  2. arrayRepresentsProbability(double[] probs)
  3. arraySame(Object[] array1, Object[] array2)
  4. arraysConvert(String[] src, int column)
  5. arraySeekDelete(final T[] arr, final T[] dest, final T... dels)
  6. arrayString(double[] test)
  7. arrayString(int[] data)
  8. arrayStringR(double[] data)
  9. arrayTransfer(int[] ids)