Kotlin Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
fun main(args : Array<String>) { /* Showing the difference between print and println statement in Kotlin */ println("1. println "); println("2. println "); print("1. print "); print("2. print"); val value = 8783.8 println("Value") println("$value") println(value) println("Value = $value") println("${value + value}") println(8783.8) } |
Output:
1 2 3 4 5 6 7 8 9 10 |
1. println 2. println 1. print 2. printValue 8783.8 8783.8 Value = 8783.8 17567.6 8783.8 |
As like System.out.println() in java println is used to print output to screen in Kotlin.
These two functions println() and print() functions to send output to the standard output in Kotlin.
print() – prints string inside the quotes.
println() – As like print() it will print the string inside the quote and the cursor moves to the beginning of the next line.
Refer kotlin program to get more understanding about print and println.