I have a list of Strings, and I want to concatenate them with spaces in between. So I'm using StringBuilder. Now if any of the Strings are null, they get stored in the StringBuilder literally as 'null'. Here is a small program to illustrate the issue:
public static void main(String ss[]) {
StringBuilder sb = new StringBuilder();
String s;
s = null;
System.out.println(sb.append("Value: ").append(s));
}
I'd expect the output to be "Value: " but it comes out as "Value: null"
Is there a way around this problem?