println and print
In this page:
println and print
println prints a value followed by a newline, while print prints without adding one. Both accept any value and call .toString on it implicitly. println is by far the more commonly used of the two, since most output benefits from ending on its own line.
Note: Use string interpolation (s"...") with println for the clearest, most readable way to build formatted output.
Example: println and print
object Main extends App {
println("This line ends with a newline")
print("This line ")
print("does not, so ")
println("this continues on the same line")
}
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 8 topics to unlock
0/8 topics done
Complete these topics first: