To output text or variables in Kotlin, you primarily use two built-in functions: println() and print().
println() FunctionThe println() function prints the text inside the parentheses, and then automatically adds a new line at the end. The next output will start on a new line.
fun main() {
println("Hello World!")
println("I am learning Kotlin.")
println("It is awesome!")
}
You can add as many println() functions as you want. Each will output on a new line.
print() FunctionThe print() function is similar to println(), but it does not insert a new line at the end of the output.
fun main() {
print("Hello World! ")
print("I will print on the same line.")
}
You can also use println() to output numbers and perform mathematical calculations directly inside the parentheses without using quotes.