0
Is there a function in Java that is equal (or similar) to Join PHP? If yes, demonstrate your use.
0
Is there a function in Java that is equal (or similar) to Join PHP? If yes, demonstrate your use.
4
Using Java 8 you can do this very neatly and easily with:
String.join(delimiter, elements);
This works in three ways:
1) Specifying the elements directly
String joined1 = String.join(",", "a", "b", "c");
2) Using array’s
String[] array = new String[] { "a", "b", "c" };
String joined2 = String.join(",", array);
3) Using iterables
List<String> list = Arrays.asList(array);
String joined3 = String.join(",", list);
If you need for android:
String android.text.TextUtils.join(CharSequence delimiter, Object[] tokens)
Example:
String joined = TextUtils.join(";", MyStringArray);
Reference:
https://stackoverflow.com/questions/1515437/java-function-for-arrays-like-phps-join
Don’t forget to reference the original link post.
Updated!! :)
Browser other questions tagged php java array
You are not signed in. Login or sign up in order to post.
What does this Join do? Join two arrays?
– user28595
Check if this answers your question: https://stackoverflow.com/questions/1515437/java-function-for-arrays-like-phps-join
– Don't Panic
@diegofm, joins 2 arrays in a string
– Don't Panic
Also: https://stackoverflow.com/a/26195047/5524514
– user28595
@diegofm, please put your answer to #Velasco accept the answer and so close the topic.
– Don't Panic
@Everson was purposely posting the link as a comment. If you want to reply, feel free :)
– user28595