Here you can find the source of arrayToStringNullable(String[] a)
Parameter | Description |
---|---|
a | a parameter |
public static String arrayToStringNullable(String[] a)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w .ja v a 2s.co m * transforms an array of strings to string with removed null elements. * @param a * @return */ public static String arrayToStringNullable(String[] a) { if (a == null) { return "[]"; } int iMax = a.length - 1; if (iMax == -1) { return "[ ]"; } StringBuilder b = new StringBuilder(); b.append('['); for (int i = 0;; i++) { if (a[i] == null) { } else { b.append(String.valueOf(a[i])); } if (i == iMax) { return b.append(']').toString(); } if (a[i + 1] == null) { //b.append(','); b.append(' '); } else { //b.append(", "); b.append(' '); } } } }