Answers for "concaténation kotlin"

0

how to concatenate in kotlin

fun main() {
    var list = listOf("Hello", "World")
 
    var result = list.joinToString("")
    print(result)
}

//It will print:
	HelloWorld

//This is another way to concatenate in Kotlin!
//Hopefully it helps!
Posted by: Guest on July-26-2021
0

how to concatenate in kotlin

//This is another way too! The Kotlin language is very special because it somewhat flexible!

//If you use vscdoe to run it just do fun main(){}

fun main(args: Array<String>) {

    val str1 = "hello"
    val str2 = "hi"
    val str3 = "bye"

    // joining using + operator
    // can also be written like this: 
    // val str4 = str1.plus(str2).plus(str3)
    val str4 = str1 + str2 + str3

    // displaying concatenated string
    println(str4)
}

//output is:
hellohibye

//Hopefully it helps I got it from the website! I did test if it works and it is working good!
Posted by: Guest on July-26-2021

Browse Popular Code Answers by Language