This isn't a true answer because I won't use here the ternary operator.
If you need to concatenate strings removing the empty ones you can write a generic function (no error checking, no optimizations, take it as an example):
public static String join(String[] array, char separator) { StringBuffer result = new StringBuffer(); for (int i = 0; i < array.length; ++i) { if (array[i] != null && array[i].length() != 0) { if (result.length() > 0) result.append(separator); result.append(array[i]); } } return result.toString(); }
It's pretty longer than the "inline" version but it works regardless the number of strings you want to join (and you can change it to use a variable number of parameters). It'll make the code where you'll use it much more clear than any sort of if tree.
Something like this:
public static String join(char separator, String... items, ) { StringBuffer result = new StringBuffer(); for (String item: items) { if (item != null && item.length() != 0) { if (result.length() > 0) result.append(separator); result.append(item); } } return result.toString(); }