Oct 10, 2018

[HDGEM] How to Convert an Array to Comma Separated String in Java

The simplest way to convert an array to comma separated String is to create a StringBuilder, iterate through the array, and add each element of the array into StringBuilder after appending comma.

            String venueGroup;          StringBuilder sb=new StringBuilder();          for(String venue: venues) {              sb.append(venue).append(",");                        }          Arrays.stream(venues).forEach(i-> sb.append(i).append(","));          venueGroup=sb.substring(0, sb.length()-1);  

Posted By Blogger to HDGEM at 3/20/2017 09:14:00 AM