-2

Suppose I executed the following Java method:

public static void print() {
    System.out.print("This is some text");
    System.out.println();
}

How many lines of output are printed? What counts as a "line of output"? I would think there are two, but I really don't know.

user700352
  • 165
  • 1
  • 9

3 Answers3

0

There will be one line of output printed because System.out.print("This is some text") does not automatically move the cursor to a new line, but System.out.println() without arguments simply prints a new line, so the overall effect is the same as that of System.out.println("This is some text"), i.e. one line of output.

You can read more about this by looking at the documentation for the PrintStream class.

arshajii
  • 127,459
  • 24
  • 238
  • 287
0

one line

System.out.print("This is some text"); <-- this is output with no new line

System.out.println(); <-- this prints a newline

You would define a "line of output" as anything output up to a newline (including the cursor)

rlay3
  • 10,002
  • 6
  • 30
  • 22
0
System.out.print("text") 

print "text" on the same line, without append new-line character.

System.out.println("text")

print "text" on a line and than adds a new-line character (\n)

kappatech
  • 479
  • 5
  • 7