Here you can find the source of printWithIndex(double[] arr)
public static String printWithIndex(double[] arr)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static String printWithIndex(List<? extends Object> list, int startIndex) { StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < list.size(); i++) { sb.append("" + (i + startIndex)).append(":").append(list.get(i)); if (i != list.size() - 1) { sb.append(", "); }//from w w w . java 2s . co m } sb.append("]"); return sb.toString(); } public static String printWithIndex(List<? extends Object> list) { return printWithIndex(list, 0); } public static String printWithIndex(double[] arr) { StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < arr.length; i++) { sb.append(i).append(":").append(arr[i]); if (i != arr.length - 1) { sb.append(", "); } } sb.append("]"); return sb.toString(); } public static String printWithIndex(int[] arr) { StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < arr.length; i++) { sb.append(i).append(":").append(arr[i]); if (i != arr.length - 1) { sb.append(", "); } } sb.append("]"); return sb.toString(); } }