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.
Read More Articles
- Declare Variables In Kotlin
- Read Data Input using Scanner in Kotlin
- Double Data type Usage and Type Conversion in Kotlin
- print and println Data Output in Kotlin
- Arithmetic Operators (Mathematical Operators) in Kotlin
- Unary Operators (Sign, Inverts, Increment, and Decrement) in Kotlin
- Equality Operators (==, !=) and Referential equality Operators (===, !==) in Kotlin
- Printing Variables and Values in Kotlin
- Float Data type Usage and Type Conversion in Kotlin
- Long Data type Usage and Type Conversion in Kotlin
- Comparison Operators in Kotlin
- Byte Data type Usage and Type Conversion in Kotlin
- Is Operator (is and !is) in Kotlin
- In Operator (in and !in) in Kotlin
- Char Data type Usage and Type Conversion in Kotlin
- Read Data Input from Command Line in Kotlin
- Assignment Operators and Augmented Assignment Operators in Kotlin
- Indexed Access Operator [, ] in Kotlin
- Read String Data Input in Kotlin
- Short Data type Usage and Type Conversion in Kotlin
- Boolean Data type Usage and Type Conversion in Kotlin
- Logical Operators in Kotlin
- Elvis Operator (?:) in Kotlin
- Repeat and Its Usage in Kotlin
- Safe Call Operator (?.) in Kotlin