Java Array to String asString(final String[] array)

Here you can find the source of asString(final String[] array)

Description

as String

License

Open Source License

Declaration

public static String asString(final String[] array) 

Method Source Code


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

import static java.util.Arrays.copyOfRange;

public class Main {
    private static final String SPACE = " ";

    public static String asString(final String[] array) {
        return asString(array, 0);
    }/*from   w w w . ja  va2  s.c  o m*/

    public static String asString(final String[] array, final int start) {
        if (array == null) {
            return "";
        }
        return asString(array, start, array.length);
    }

    public static String asString(final String[] array, final int start, final int end) {
        if (array == null || array.length == 0 || start >= end) {
            return "";
        }
        if (array.length < end) {
            return asString(array, start);
        }
        final String[] part = copyOfRange(array, start, end);
        return String.join(SPACE, part);
    }
}

Related

  1. arrayToStringDelimited(final String[] array, final String delimiter)
  2. arrayToStringNullable(String[] a)
  3. arrayToStrings(String[] s, String delimiter)
  4. arrayToStringWithDifferenceOrientedFormat(double[] values, int minDigits)
  5. arrayToStringWithPrefix(T[] array, String splitter, String prefix)
  6. asString(int[] objects, String separator)
  7. asString(String[] arrayParameter)
  8. asString(T[] objects)
  9. asStringOn(StringBuilder sb, Object[] items, String separator)