Kotlin – Convert comma-separated String into List & List into one String


This Kotlin tutorial gives you a simple example that helps to convert comma-separated String into List & List into one String.

I. Technology

– Java 1.8
– Kotlin 1.1.2

II. Practice

1. String into List

Use CharSequence.split() method that returns a List, then map() each item with CharSequence.trim() method to remove [space] character.


2. List into String

Use joinToString() method with prefix, postfix, limit 3 elements to be appended, and truncated by string “…more…”:


By grokonez | August 29, 2017.

Last updated on September 25, 2018.

Related Posts

Got Something To Say:

Your email address will not be published. Required fields are marked *