The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

20121024

how to output an array of strings to a comma separated list of strings

import java.util.Arrays;

public class StringTest {
    private static String[] colIds = {"abc","def","ghi"};
 

    public static void main(String[] args) {
        String s = Arrays.toString(colIds);
         // remove leading and trailing brackets, i.e. "[" and "]"
        System.out.println(s.substring(1, s.length()-1));
    }
}



the output will look like this:
abc, def, ghi

if you take away the substring code, then the output will look like this:
[abc, def, ghi]

No comments:

Post a Comment