String Interpolation
String Interpolation
Kotlin allows you to directly insert variables in strings using the dollor sign($) and with curly brackets {} if it is an expression.
fun main(args:Array<String>) { var msg:String="Kotlin Test Message"
print("String interpolation $msg") print("Length of the message ${msg.length}") var a:Int=10
var b:Int=15
print("Addition of $a and $b is ${a+b}") }
Output
String interpolation Kotlin Test Message
Length of the message 19
Addition of 10 and 15 is 25
Comments
Post a Comment