Introduction
We use print and println to show messages or results on the screen. This helps us see what our program is doing.
We use print and println to show messages or results on the screen. This helps us see what our program is doing.
print("message") println("message")
print shows the message but stays on the same line.
println shows the message and moves to the next line.
Hello World on the same line.print("Hello") print(" World")
Hello and then World on the next line.println("Hello") println("World")
\n inside print moves to a new line manually.print("Hello\n") print("World")
This program shows how print and println work together to print text on the screen.
fun main() { print("Hello") print(" ") println("World") println("Welcome to Kotlin!") }
Remember, println always adds a new line after printing.
You can use print multiple times to build a line before moving to the next.
print shows text without moving to a new line.
println shows text and moves to the next line.
Use them to display messages and results clearly.
print and println in Kotlin?print behaviorprint outputs text exactly as given and stays on the same line.println behaviorprintln outputs text and then moves the cursor to the next line.print outputs text without a newline; println adds a newline after output. -> Option Cprintln("Hello") uses correct function call syntax with parentheses and quotes.println("Hello") prints "Hello" and moves to a new line automatically.print("Hi")
println(" there")
print("Welcome")print("Hi") outputs "Hi" without newline.println(" there") outputs " there" and moves to next line.print("Welcome") outputs "Welcome" on the new line.print("Hello")
println "World"print("Hello") is correct with parentheses and quotes.println "World" is missing parentheses around the argument, which is required in Kotlin.print("1 2 3") outputs "1 2 3" on the same line.println("Done") prints "Done" and moves to the next line.Pass the test and this pattern moves unknown