print and println Data Output in Kotlin


print Data Output

Definition

In Kotlin, print() function to print output on the screen or standard output. print() function calls internally Java's System.out.print() method to print and passes its params. you can print all type of variables (like Int, Float, Double, Long, Char, and String) value to print the console.

  • Which is equivalent to Java's System.out.print() method.

Syntax

print("any data")

Definitions in Kotlin

fun print(message: Any?)
fun print(message: Int)
fun print(message: Long)
fun print(message: Byte)
fun print(message: Short)
fun print(message: Char)
fun print(message: Boolean)
fun print(message: Float)
fun print(message: Double)
fun print(message: CharArray)

print Data Output in Kotlin Example Program

// Print Kotlin example program
// Data Input and Output Kotlin Programs, Basic Kotlin Programs

fun main(args: Array < String > ) {
    
    //Print Values using print
    print("Print Output ")
    print("In Kotlin")
}

Sample Output

Print Output In Kotlin

println Data Output

Definition

In Kotlin, println() function to print output on the screen or standard output. print() function calls internally Java's System.out.println() method to print and passes its params. you can print all type of variables (like Int, Float, Double, Long, Char, and String) value to print the console.

  • Which is equivalent to Java's System.out.println() method.
  • println = print + newline

Syntax

println("any data")

Definitions in Kotlin

fun println(message: Any?)
fun println(message: Int)
fun println(message: Long)
fun println(message: Byte)
fun println(message: Short)
fun println(message: Char)
fun println(message: Boolean)
fun println(message: Float)
fun println(message: Double)
fun println(message: CharArray)

println Data Output in Kotlin Example Program

// Println Kotlin example program
// Data Input and Output Kotlin Programs, Basic Kotlin Programs

fun main(args: Array < String > ) {
    
    //Print Values using println
    println("Print Output ")
    println("In Kotlin")
}

Sample Output

Print Output
In Kotlin

Difference Between print() and println()

print()

  • 'print' prints String which is inside the doubles quotes.

println()

  • 'println' does the same job of the print() function and output screen cursor goes to the beginning of the next line.