# Which line separator in println?

**URL:** <https://users.scala-lang.org/t/which-line-separator-in-println/12375>\
**Category:** Question\
**Created:** [September 4, 2026, 2:17pm UTC](https://users.scala-lang.org/t/which-line-separator-in-println/12375 "2026-09-04T14:17:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![charpov](https://users.scala-lang.org/user_avatar/users.scala-lang.org/charpov/32/500_2.png) [@charpov](https://users.scala-lang.org/u/charpov)\
**Post date:** [September 4, 2026, 2:17pm UTC](https://users.scala-lang.org/t/which-line-separator-in-println/12375/1 "2026-09-04T14:17:50Z")

</div>

The documentation for `Predef.println` (or `Console.println`) states:

> Prints out an object to the default output, followed by a newline character.

But it looks like the default output is `java.lang.System.out` and that `Predef.println` uses `out.println`, which states:

> The line separator string is defined by the system property `line.separator`, and is not necessarily a single newline character (`'\n'`).

So, which is it?

---

<div class="post-metadata">

**Author:** ![WojciechMazur](https://users.scala-lang.org/user_avatar/users.scala-lang.org/wojciechmazur/32/2565_2.png) [@WojciechMazur](https://users.scala-lang.org/u/WojciechMazur)\
**Post date:** [September 4, 2026, 2:35pm UTC](https://users.scala-lang.org/t/which-line-separator-in-println/12375/2 "2026-09-04T14:35:06Z")

</div>

> system property `line.separator`, and is not necessarily a single newline character (`'\n'`).

This is the important part - on normal systems that’s `\n` by default, but on Windows that’s `\r\n` digraph.

Since both `Console.withOut` and `System.setOut` allow to set a custom `PrintStream` the final result depends on the implementation of non-final `PrintStream` instance, since `PrintStream.println` is not a final method.

---

<div class="post-metadata">

**Author:** ![charpov](https://users.scala-lang.org/user_avatar/users.scala-lang.org/charpov/32/500_2.png) [@charpov](https://users.scala-lang.org/u/charpov)\
**Post date:** [September 4, 2026, 2:51pm UTC](https://users.scala-lang.org/t/which-line-separator-in-println/12375/3 "2026-09-04T14:51:08Z")

</div>

I understand that, but isn’t the documentation on the Scala side a bit misleading? Maybe it should say: “followed by a line separator”?

---

<div class="post-metadata">

**Author:** ![philipschwarz](https://users.scala-lang.org/user_avatar/users.scala-lang.org/philipschwarz/32/3130_2.png) [@philipschwarz](https://users.scala-lang.org/u/philipschwarz)\
**Post date:** [September 4, 2026, 5:19pm UTC](https://users.scala-lang.org/t/which-line-separator-in-println/12375/4 "2026-09-04T17:19:23Z")

</div>

FWIW, I dug up this very old slide (apologies for the gratuitous, cringeworthy mugshot)

 ![image](https://users.scala-lang.org/uploads/default/original/2X/8/85dbb92c594d1999a27bff3802a56ab0371884d6.png)

---

<div class="post-metadata">

**Author:** ![SolalPirelli](https://users.scala-lang.org/user_avatar/users.scala-lang.org/solalpirelli/32/3530_2.png) [@SolalPirelli](https://users.scala-lang.org/u/SolalPirelli)\
**Post date:** [September 10, 2026, 2:15pm UTC](https://users.scala-lang.org/t/which-line-separator-in-println/12375/5 "2026-09-10T14:15:46Z")

</div>

Fixing this in [Doc: clarify behavior of line-related functions by SolalPirelli · Pull Request #27047 · scala/scala3 · GitHub](https://github.com/scala/scala3/pull/27047)
