← Back to Scala Course | Chapter 1: Setup & Basics | Lesson 7 of 8

println and print

In this page:

  1. println and print

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

markup
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")
}
🔒

Chapter Quiz — Complete all 8 topics to unlock

0/8 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.