Java Integer Array to String intArrayToString(int[] array)

Here you can find the source of intArrayToString(int[] array)

Description

Creates a string representation of the given array of type int[] (this representation can be parsed using the method parseIntegerArray).

License

Open Source License

Parameter

Parameter Description
array the array

Return

string representation of the given array

Declaration

public static String intArrayToString(int[] array) 

Method Source Code

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

public class Main {
    /**//from  w ww .  j  ava  2s. c o  m
     * Creates a string representation of the given array of type int[] (this representation
     * can be parsed using the method parseIntegerArray).
     * @param array the array
     * @return string representation of the given array
     */
    public static String intArrayToString(int[] array) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        for (int a : array) {
            sb.append(a).append(", ");
        }
        if (sb.lastIndexOf(", ") != -1)
            sb.delete(sb.lastIndexOf(", "), sb.length());
        sb.append("]");
        return sb.toString();
    }
}

Related

  1. intArrayToString(int vals[])
  2. intArraytoString(int[] a)
  3. intArrayToString(int[] a)
  4. intArrayToString(int[] a, String separator)
  5. intArrayToString(int[] arr)
  6. intArrayToString(int[] array, boolean whiteSpaceSeperator)
  7. intArrayToString(int[] ia)
  8. intArrayToString(int[] iarray, int count)
  9. intArrayToString(int[] intArray)