16

I guess it's related to println()'s newline functionality ('\n'), but in abbreviated letter-based form, that would be nl rather than ln. Thank you for any comments.

Rahul
  • 44,383
  • 11
  • 84
  • 103
user2911290
  • 1,396
  • 1
  • 16
  • 26
  • 6
    println - print line. Meaning it will use **\n** at the end of the printed line. – Tafari Nov 25 '13 at 09:47
  • Its not asking to print new line but it prints the given line with \n at the end. – Govan Nov 25 '13 at 09:48
  • println - Print a line(a complete line, which is terminated with a new line character(default line separator) or the line separator property). – Rahul Nov 25 '13 at 09:49
  • If you got your answer, go ahead and accept it. Please do not add it to your question. It defeats the whole purpose of a Q&A if you're going to include the answer in your question itself. Or else, if you've something new to share with us(which hasn't been posted already), you can post a new answer to your own question also. – Rahul Nov 25 '13 at 10:03

5 Answers5

23

It's historic.

Pascal had write and writeln.

write would output a string, leaving the cursor at the end of that string.

writeln (where ln was short for "line") would write a whole line of text and move the cursor to the start of the next line, typically by automatically appending a CRLF or some other OS-dependent control sequence.

Java inherited the abbreviation, but used print instead of write.

Alnitak
  • 334,560
  • 70
  • 407
  • 495
3

Hi check if this is helpful..

http://docs.oracle.com/javase/7/docs/api/java/io/PrintStream.html

You can find it under the heading Class PrintStream

ln simply means LINE - it prints the character/string in a NEW LINE.

MusicLovingIndianGirl
  • 5,909
  • 9
  • 34
  • 65
1

println stands for printline.

There is nothing special about it :P It will print a new line instead of printing it on the same line.

user1021726
  • 638
  • 10
  • 23
  • 5
    A source would be welcome. OP asks what it stands for, and it's possible to find other hypothesis, like the fact "ln" looks like "\n". – Denys Séguret Nov 25 '13 at 09:48
  • 2
    Referring to your edit - *It will print a new line instead of printing it on the same line*. Wrong. it'll print the line and end it with a new line character. – Rahul Nov 25 '13 at 09:50
  • @R.J According to http://docs.oracle.com/javase/7/docs/api/java/io/PrintStream.html#println(java.lang.String), it will print the string and then invoke println() meaning it will print a new empty line. – user1021726 Nov 25 '13 at 09:51
  • The order is important here. If nothing is specified, it prints nothing(blank) and terminates it with the new line character. – Rahul Nov 25 '13 at 09:52
  • @dystroy IMO OP is just overthinking it. Confusing \n with nl or ln. In regards to his question of what "ln" stands for: it stands for line. – user1021726 Nov 25 '13 at 09:56
  • @dystroy the source is history - other languages used `fooln` to mean do `foo` followed by a _move to next line_ operation. – Alnitak Nov 25 '13 at 10:13
  • @Alnitak I know that. What I'm curious about is if historically "ln" stands for "\n" (like `print + \n`) or for an abbreviation of line. But that interesting part of the question is probably off-topic for SO. – Denys Séguret Nov 25 '13 at 10:18
  • 1
    @dystroy no, it doesn't (and AFAIK cannot) stand for `\n` because that's a "C"ism, and Pascal had `writeln` before C existed. – Alnitak Nov 25 '13 at 10:21
  • @Alnitak That's a damn good point there. I had totally forgotten the pascal literals (`#13#10` wasn't it ?). – Denys Séguret Nov 25 '13 at 10:23
0

println() method Terminates the current line by writing the line separator string. The line separator string is defined by the system property line.separator, and is not necessarily a single newline character ('\n').

 public void println() {
     newLine();
 }

Also, there are overloaded methods println(String s), println(Char c), println(Double d), println(Float f), println(Long l), println(int i), println(bool b).

Here is a link which gives all code.
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/io/PrintStream.java#PrintStream.println%28%29.

Bosko Mijin
  • 3,287
  • 3
  • 32
  • 45
0

println -> print line.

That means that it will print the line you gave it through the parameter, and goes with the cursor to the next line, waiting for another input.

Hitman
  • 588
  • 4
  • 10