Kotlin Output (Print Text)
Kotlin Output (Print)
The println()
function is used to output values/print text:
You can add as many println()
functions as you want. Note that it will add a new line for each function:
例子
fun main() {
println("Hello World!")
println("I am learning Kotlin.")
println("It is awesome!")
}
亲自尝试 »
You can also print numbers, and perform mathematical calculations:
The print() function
There is also a print()
function, which is similar to println()
. The only difference is that it does not insert a new line at the end of the output:
例子
fun main() {
print("Hello World! ")
print("I am learning Kotlin. ")
print("It is awesome!")
}
亲自尝试 »
Note that we have added a space character to create a space between the sentences.