String.Join Method

Definition

Overloads

Join(String, String[])

Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter.

Join(String, IIterable)

Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter.

Join(ICharSequence, ICharSequence[])

Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter.

Join(ICharSequence, IIterable)

Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter.

Join(String, String[])

Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter.

public static string Join (string delimiter, params string[]? elements);
static member Join : string * string[] -> string

Parameters

delimiter
String

the delimiter that separates each element

elements
String[]

the elements to join together.

Returns

a new String that is composed of the elements separated by the delimiter

Remarks

Java documentation for java.lang.String.join(java.lang.CharSequence, java.lang.CharSequence).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Join(String, IIterable)

Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter.

public static string Join (string delimiter, Java.Lang.IIterable elements);
static member Join : string * Java.Lang.IIterable -> string

Parameters

delimiter
String

a sequence of characters that is used to separate each of the elements in the resulting String

elements
IIterable

an Iterable that will have its elements joined together.

Returns

a new String that is composed from the elements argument

Remarks

Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter.

<blockquote>For example,

{@code
                List<String> strings = List.of("Java", "is", "cool");
                String message = String.join(" ", strings);
                //message returned is: "Java is cool"

                Set<String> strings =
                    new LinkedHashSet<>(List.of("Java", "is", "very", "cool"));
                String message = String.join("-", strings);
                //message returned is: "Java-is-very-cool"
            }

</blockquote>

Note that if an individual element is null, then "null" is added.

Added in 1.8.

Java documentation for java.lang.String.join(java.lang.CharSequence, java.lang.Iterable<? extends java.lang.CharSequence>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Join(ICharSequence, ICharSequence[])

Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter.

[Android.Runtime.Register("join", "(Ljava/lang/CharSequence;[Ljava/lang/CharSequence;)Ljava/lang/String;", "", ApiSince=26)]
public static string Join (Java.Lang.ICharSequence delimiter, params Java.Lang.ICharSequence[]? elements);
[<Android.Runtime.Register("join", "(Ljava/lang/CharSequence;[Ljava/lang/CharSequence;)Ljava/lang/String;", "", ApiSince=26)>]
static member Join : Java.Lang.ICharSequence * Java.Lang.ICharSequence[] -> string

Parameters

delimiter
ICharSequence

the delimiter that separates each element

elements
ICharSequence[]

the elements to join together.

Returns

a new String that is composed of the elements separated by the delimiter

Attributes

Remarks

Java documentation for java.lang.String.join(java.lang.CharSequence, java.lang.CharSequence).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Join(ICharSequence, IIterable)

Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter.

[Android.Runtime.Register("join", "(Ljava/lang/CharSequence;Ljava/lang/Iterable;)Ljava/lang/String;", "", ApiSince=26)]
public static string Join (Java.Lang.ICharSequence delimiter, Java.Lang.IIterable elements);
[<Android.Runtime.Register("join", "(Ljava/lang/CharSequence;Ljava/lang/Iterable;)Ljava/lang/String;", "", ApiSince=26)>]
static member Join : Java.Lang.ICharSequence * Java.Lang.IIterable -> string

Parameters

delimiter
ICharSequence

a sequence of characters that is used to separate each of the elements in the resulting String

elements
IIterable

an Iterable that will have its elements joined together.

Returns

a new String that is composed from the elements argument

Attributes

Remarks

Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter.

<blockquote>For example,

{@code
                List<String> strings = List.of("Java", "is", "cool");
                String message = String.join(" ", strings);
                //message returned is: "Java is cool"

                Set<String> strings =
                    new LinkedHashSet<>(List.of("Java", "is", "very", "cool"));
                String message = String.join("-", strings);
                //message returned is: "Java-is-very-cool"
            }

</blockquote>

Note that if an individual element is null, then "null" is added.

Added in 1.8.

Java documentation for java.lang.String.join(java.lang.CharSequence, java.lang.Iterable<? extends java.lang.CharSequence>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to