How to convert Collection to String in Java
Many times we need to convert any Collection like Set or List into String like comma separated or any other delimiter delimited String. Though this is quite a trivial job for a Java programmer as you just need to Iterate through loop and create a big String where individual String are separated by delimiter, you still need to handle cases like last element should not have delimiter or at bare minimum you need to test that code. I like Joshua Bloach advise on Effective Java to use libraries for those common task let it be internal proprietary library or any open source library as used in previous examples of Spring, Apache Commons or Google’s Guava but point is that you should avoid converting ArrayList to String like common task by yourself on application code.