Here you can find the source of arrayToString(String[] array)
Parameter | Description |
---|---|
array | The array to be processed |
public static String arrayToString(String[] array)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w ww .j a va 2s.c o m*/ * Convert an Array to a comma seperated String * @param array The array to be processed * @return The Array with comma seperated elements */ public static String arrayToString(String[] array) { String output = ""; for (int i = 0; i < array.length; i++) { if (output.equals("")) { output = output + array[i]; } else { output = output + ", " + array[i]; } } return output; } /** * Convert an Array to a comma seperated String, uses the method .toString() * @param array The array to be processed * @return The Array with comma seperated elements */ public static String arrayToString(Object[] array) { String output = ""; for (int i = 0; i < array.length; i++) { if (output.equals("")) { output = output + array[i]; } else { output = output.toString() + ", " + array[i]; } } return output; } /** * Convert an Array to a comma seperated String * @param array The array to be processed * @return The Array with comma seperated elements */ public static String arrayToString(double[] array) { String output = ""; for (int i = 0; i < array.length; i++) { if (output.equals("")) { output = output + array[i]; } else { output = output + ", " + array[i]; } } return output; } }