Java Array to String arrayToString(Object[] array)

Here you can find the source of arrayToString(Object[] array)

Description

array To String

License

Open Source License

Declaration

public static String arrayToString(Object[] array) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String arrayToString(Object[] array) {
        return arrayToString(array, ",");
    }/* w w w  .j  a v a  2  s. c o m*/

    public static String arrayToString(Object[] array, String delimeter, int start, int end) {
        StringBuilder sb = new StringBuilder();
        for (int i = start; i < end; i++) {
            Object o = array[i];
            sb.append(String.valueOf(o));
            sb.append(delimeter);
        }
        deleteLastDelimeter(sb, delimeter);
        return sb.toString();
    }

    public static String arrayToString(Object[] array, String delimeter) {
        return arrayToString(array, delimeter, 0, array.length);
    }

    public static void deleteLastDelimeter(StringBuilder sb, String delimeter) {
        if (sb.length() > delimeter.length()) {
            sb.delete(sb.length() - delimeter.length(), sb.length());
        }
    }
}

Related

  1. arrayToString(Object[] array)
  2. arrayToString(Object[] array)
  3. arrayToString(Object[] array)
  4. arrayToString(Object[] array)
  5. arrayToString(Object[] array)
  6. arrayToString(Object[] array)
  7. arrayToString(Object[] array)
  8. arrayToString(Object[] array)
  9. arrayToString(Object[] array)