Here you can find the source of printArray(char[] array)
public static void printArray(char[] array)
//package com.java2s; //License from project: Open Source License public class Main { public static void printArray(char[] array) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < array.length; ++i) { if (i == 0) { buf.append("["); buf.append("'").append(array[i]).append("'"); } else { buf.append(","); buf.append("'").append(array[i]).append("'"); }/*www. ja v a 2 s. co m*/ if (i == array.length - 1) { buf.append("]"); } } System.out.println(buf.toString()); } public static String toString(String[] a) { StringBuilder buf = new StringBuilder(); buf.append("["); if (a.length > 0) { buf.append("\"").append(a[0]).append("\""); } for (int i = 1; i < a.length; ++i) { String w = a[i]; buf.append(", ").append("\"").append(w).append("\""); } buf.append("]"); return buf.toString(); } }