Task 9 of 11 · 0 solved · 11 to go0%
You can read the problem, but answers are checked only for signed-in students. Sign in to answer →

1.1 Output — print vs println

Lesson

print versus println

One letter, a big difference. println prints the text and moves to a new line. print prints without a line break — the next output lands on the same line, right after.


Not: one statement = one line

Two prints in a row print side by side with no space: print("cat"); print("dog") gives catdog. A new line happens only where there is a println.


Worked example

System.out.print("Hello");     // no line break
System.out.print("World");     // joins on the same line
System.out.println("!");       // breaks the line after
System.out.println("Bye");     // Bye on its own line

Output is two lines: HelloWorld! then Bye.


▶ Try it: run this, then change something and run it again.



How many lines does this print?

System.out.print("x");
System.out.print("y");
System.out.println("z");
System.out.println("w");

What is on the first line?

System.out.print("a");
System.out.print("b");
System.out.println("c");
System.out.print("d");

Type exactly what this prints:

System.out.print("cat");
System.out.print("dog");

True or false?


Which command makes the next output start on a new line?


Sort each statement by what it does.