Here you can find the source of arrayToString(int[] array)
public static String arrayToString(int[] array)
//package com.java2s; //License from project: Open Source License public class Main { public static String arrayToString(int[] array) { StringBuilder output = new StringBuilder(); for (int i = 0; i < array.length - 1; i++) { output.append(String.format("%d\t", array[i])); }/*from ww w. j a v a 2 s. c om*/ output.append(String.format("%d", array[array.length - 1])); return output.toString(); } public static String arrayToString(double[] array) { StringBuilder output = new StringBuilder(); for (int i = 0; i < array.length - 1; i++) { output.append(String.format("%.2f\t", array[i])); } output.append(String.format("%.2f", array[array.length - 1])); return output.toString(); } public static String arrayToString(double[] array, String format) { StringBuilder output = new StringBuilder(); for (int i = 0; i < array.length - 1; i++) { output.append(String.format(format + "\t", array[i])); } output.append(String.format(format, array[array.length - 1])); return output.toString(); } public static String arrayToString(double[] array, int digit) { StringBuilder output = new StringBuilder(); for (int i = 0; i < array.length - 1; i++) { output.append(String.format("%." + digit + "f\t", array[i])); } output.append(String.format("%." + digit + "f", array[array.length - 1])); return output.toString(); } }