Program to convert string to character array in Kotlin
package com.includehelp
import java.util.*
//Main Function, entry Point of Program
fun main(args: Array<String>) {
// InputStream to get Input
val scanner = Scanner(System.`in`)
//Input String
print("Enter String : ")
var str = scanner.nextLine()
//convert String to Character Array
val charArray = str.toCharArray()
//Print Character Array get from String
println("Character Array Elements : ${charArray.contentToString()} ")
}
Run 1:
-----
Enter String : IncludeHelp India Pvt Ltd
Character Array Elements : [I, n, c, l, u, d, e, H, e, l, p, , I, n, d, i, a, , P, v, t, , L, t, d]
--------
Run 2:
----
Enter String : Corona Virus Covid-19 Panidimic
Character Array Elements : [C, o, r, o, n, a, , V, i, r, u, s, , C, o, v, i, d, -, 1, 9, , P, a, n, i, d, i, m, i, c]
Program to convert string to character array in Kotlin
need an explanation for this answer? contact us directly to get an explanation for this answer