This is profoundly simple, yet I’ve seen many variants, and I don’t see my own practice much elsewhere. Given:
Iterable<String> strings;
create a String containing all the strings, separated by commas.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Java-8 version
With Java 8, luckily, there is finally a standard way to do this:
Unfortunately, there’s not an easier way to get from an
Iterableto aStream(yet)Pre Java-8 version
Use
From
http://commons.apache.org/lang/
If you want to do it yourself, I sometimes do