You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Hubert Wojciechowski (Jira)" <ji...@apache.org> on 2020/10/28 18:32:00 UTC
[jira] [Comment Edited] (LANG-1593) Common behaviour for
StringUtils join APIs when called with char or String delimiter
[ https://issues.apache.org/jira/browse/LANG-1593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17222338#comment-17222338 ]
Hubert Wojciechowski edited comment on LANG-1593 at 10/28/20, 6:31 PM:
-----------------------------------------------------------------------
I have added new methods for all of the Java primitives,
{code:java}
public static String join(final int[] array, final String separator)
{code}
and
{code:java}
public static String join(final int[] array, final String separator, final int startIndex, final int endIndex)
{code}
All methods with char as argument were changed to
{code:java}
public static String join(final byte[] array, final char separator, final int startIndex, final int endIndex) {
return join(array, Character.toString(separator), startIndex, endIndex);
}
{code}
was (Author: hubertwo):
I have added new methods for all of the Java primitives,
{code:java}
public static String join(final int[] array, final String separator)
{code}
and
{code:java}
public static String join(final int[] array, final String separator, final int startIndex, final int endIndex)
{code}
All methods with char as argument were changed to
{code:java}
public static String join(final byte[] array, final char separator, final int startIndex, final int endIndex) {
return join(array, Character.toString(separator), startIndex, endIndex);
}
{code}
> Common behaviour for StringUtils join APIs when called with char or String delimiter
> ------------------------------------------------------------------------------------
>
> Key: LANG-1593
> URL: https://issues.apache.org/jira/browse/LANG-1593
> Project: Commons Lang
> Issue Type: Improvement
> Affects Versions: 3.4, 3.11
> Reporter: Kiruahxh
> Priority: Minor
> Time Spent: 10m
> Remaining Estimate: 0h
>
> For now, join(int[], char) is working well.
> However, the same join method called with a string delimiter behaves differently : it returns a single memory address which is not the desired behavior.
> I think that, for coherence, calling StringUtils with a char or String delimiter should return the exact same value.
> Ex :
> {code:java}
> CLASSPATH="./commons-lang3-3.11.jar" jshell
> | Welcome to JShell -- Version 11.0.8
> jshell> import org.apache.commons.lang3.StringUtils
> jshell> int[] arr = {1, 2, 3, 4, 5, 6, 7};
> jshell> String result = StringUtils.join(arr, '-');
> result ==> "1-2-3-4-5-6-7"
> jshell> String result = StringUtils.join(arr, "-");
> result ==> "[I@69663380-"
> {code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)