Java Array to String arrayToString(int[] subset)

Here you can find the source of arrayToString(int[] subset)

Description

array To String

License

Open Source License

Declaration

public static String arrayToString(int[] subset) 

Method Source Code

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

public class Main {
    public static String arrayToString(int[] subset) {
        StringBuilder sb = new StringBuilder("[");
        for (int i = 0; i < subset.length - 1; ++i)
            sb.append(subset[i] + ",");
        sb.append(subset[subset.length - 1] + "]");
        return sb.toString();
    }/*w  w w. j av a2  s  . c  o m*/

    public static String arrayToString(double[] subset) {
        StringBuilder sb = new StringBuilder("[");
        for (int i = 0; i < subset.length - 1; ++i)
            sb.append(subset[i] + ",");
        sb.append(subset[subset.length - 1] + "]");
        return sb.toString();
    }

    public static String arrayToString(Object[] subset) {
        StringBuilder sb = new StringBuilder("[");
        for (int i = 0; i < subset.length - 1; ++i)
            sb.append(subset[i].toString() + ",");
        sb.append(subset[subset.length - 1].toString() + "]");
        return sb.toString();
    }
}

Related

  1. arrayToString(int[] array)
  2. arrayToString(int[] array)
  3. arrayToString(int[] ary)
  4. arrayToString(int[] c, String separator)
  5. arrayToString(int[] s)
  6. arrayToString(int[][] array)
  7. arrayToString(Object arbitraryArray)
  8. arrayToString(Object array)
  9. arrayToString(Object array)