| Author |
saprating strings with commas one by one
|
Arun M'Purushothaman
Greenhorn
Joined: Mar 14, 2003
Posts: 16
|
|
|
I need to get a single string from many strings which should be connected with commas. how i can do it with java?
|
Nothing is impossible, even the word impossible says 'i m possible'.
|
 |
Andy Bowes
Ranch Hand
Joined: Jan 14, 2003
Posts: 171
|
|
|
Try using a StringBuffer and then loop through the Strings that you wish to concetnate passing it to the append() method on the StringBuffer.
|
Andy Bowes<br />SCJP, SCWCD<br />I like deadlines, I love the whoosing noise they make as they go flying past - Douglas Adams
|
 |
Deepak A
Ranch Hand
Joined: Oct 04, 2001
Posts: 120
|
|
Andy, Give him the code dear. Okie here u go, Assuming i have a 100 strings in a String array arr. StringBuffer stringbuffer = new StringBuffer(200); for(int i = 0;i < arr.length; i++ ) { if(!String.valueOf( arr[i] ).equals("null")) { if(i != 0)stringbuffer.append(","); stringbuffer.append( arr[i] ); } } System.out.println( stringbuffer ); Give it a shot dude.Tell me if it doesnt work.Try some R&D okie?? I havent tried compiling and runing the program.
|
Face Off.
|
 |
 |
|
|
subject: saprating strings with commas one by one
|
|
|