Kotlin Print And Println

Chapter: Kotlin Last Updated: 22-09-2018 06:12:09 UTC

Program:

            /* ............... START ............... */
                
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)

}
                /* ............... END ............... */
        

Output

1. println
2. println
1. print 2. printValue
8783.8
8783.8
Value = 8783.8
17567.6
8783.8

Notes:

  • 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.

Tags

Kotlin,Print And Println , Kotlin Basic Input/Output, kotlin print to console, kotlin print example,kotlin print newline

Similar Programs Chapter Last Updated
Kotlin Continue Kotlin 02-03-2018
Kotlin Break Statement Kotlin 27-01-2018
Kotlin For Loop Kotlin 30-11-2017
Kotlin Do While Loop Kotlin 19-11-2017
Kotlin While Loop Kotlin 19-11-2017
Kotlin When Statement Kotlin 18-11-2017
Kotlin Nested If Kotlin 18-11-2017
Kotlin If Else If Statement Kotlin 22-09-2018
Kotlin If Statement Kotlin 17-11-2017
Kotlin Type Conversion Kotlin 17-11-2017
Kotlin Logical Operators Kotlin 17-11-2017
Kotlin Assignment Operators Kotlin 15-11-2017
Kotlin Arithmetic Operators Kotlin 15-11-2017
Kotlin Data Types Kotlin 12-11-2017
Kotlin Variables Example Kotlin 11-11-2017
Kotlin Comments Example Kotlin 11-11-2017
Kotlin Hello World Kotlin 11-11-2017

1