I have the list of strings
List<String> lst;
I need to transform that list into a string as follows:
List<String> lst = new ArrayList<String>();
lst.add("String 1");
lst.add("String 2");
lst.add("String 3");
The String I want to get is:
"String 1 + String 2 + String 3"
If
List<String> lst = new ArrayList<String>();
lst.add("String 1");
then I just want String 1
If lst.isEmpty()
then I want ""
.
Is it possible to do that in a flexible way and avoid writing multiple if-else if
?
UPD: I'm on Java 7