Here you can find the source of arrayToString(double[] xs)
public static String arrayToString(double[] xs)
//package com.java2s; /*//from w ww . jav a 2s. co m * Copyright 2014 Attila Szegedi, Daniel Dekany, Jonathan Revusky * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { public static String arrayToString(double[] xs) { StringBuilder sb = new StringBuilder(); sb.append('['); for (double x : xs) { if (sb.length() != 1) sb.append(", "); sb.append(x); } sb.append(']'); return sb.toString(); } public static String arrayToString(Object[] array) { if (array == null) return "null"; StringBuilder sb = new StringBuilder(); sb.append('['); for (int i = 0; i < array.length; i++) { if (i != 0) { sb.append(", "); } sb.append(array[i]); } sb.append(']'); return sb.toString(); } public static String arrayToString(Object[][] arrayArray) { if (arrayArray == null) return "null"; StringBuilder sb = new StringBuilder(); sb.append('['); boolean first = true; for (Object[] array : arrayArray) { if (!first) { sb.append(", "); } else { first = false; } sb.append(arrayToString(array)); } sb.append(']'); return sb.toString(); } public static String arrayToString(int[] array) { if (array == null) return "null"; StringBuilder sb = new StringBuilder(); sb.append('['); for (int i = 0; i < array.length; i++) { if (i != 0) { sb.append(", "); } sb.append(array[i]); } sb.append(']'); return sb.toString(); } public static String arrayToString(int[][] xss) { if (xss == null) return "null"; StringBuilder sb = new StringBuilder(); sb.append('['); for (int i = 0; i < xss.length; i++) { if (i != 0) { sb.append(", "); } sb.append(arrayToString(xss[i])); } sb.append(']'); return sb.toString(); } public static String arrayToString(char[] array) { if (array == null) return "null"; StringBuilder sb = new StringBuilder(); sb.append('['); for (int i = 0; i < array.length; i++) { if (i != 0) { sb.append(", "); } sb.append(array[i]); } sb.append(']'); return sb.toString(); } public static String arrayToString(boolean[] array) { if (array == null) return "null"; StringBuilder sb = new StringBuilder(); sb.append('['); for (int i = 0; i < array.length; i++) { if (i != 0) { sb.append(", "); } sb.append(array[i]); } sb.append(']'); return sb.toString(); } }