Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Name: jl125535 Date: 03/17/2004 A DESCRIPTION OF THE REQUEST : The class java.lang.String lacks a facility to merge a String array to a single String with support for a delimiter that's inserted between the array elements. This facility should be the opposite of java.lang.String.split . JUSTIFICATION : The String merge/join facility is very common thing and can be used in many situations. It would make the life of the majority of Java developers easier. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - The best way to provide a String merge/join facility would be to implement a new String constructor with two parameters: a String array and a delimiter. public String(String[] tokens, String delimiter) { // The implementation is left as an exercise to the reader ;-) } ACTUAL - The following pseudo code shows how the new constructor should work : String[] tokens = new String[]{"Hello", "World!"}; String greeting = new String(tokens, ", "); System.out.println(greeting); The output of the code snippet should be: Hello, World! CUSTOMER SUBMITTED WORKAROUND : A workaround would be to implement a helper mewthod that does the merge. (Incident Review ID: 240506) ======================================================================
|