Answers for "how to concatenate in kotlin"

0

how to concatenate in kotlin

fun main() {

    val a = 11
    val b = 10

        println("$a is larger than $b.")
        println("max variable holds value of a.")
        
}

//It will output!
11 is larger than 10.
max variable holds value of a.


//You conactenate using the $ symbol and put the var in it!
//Example is $a or $b

//Hopefully it helps!
Posted by: Guest on July-26-2021
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

Code answers related to "how to concatenate in kotlin"

Browse Popular Code Answers by Language