简体   繁体   English

println方法 - 最后2个字母(l&n)代表什么?

[英]println method - what do the last 2 letters (l & n) stand for?

I guess it's related to println() 's newline functionality ( '\\n' ), but in abbreviated letter-based form, that would be nl rather than ln . 我猜这与println()的换行功能( '\\n' )有关,但是在缩写的基于字母的形式中,这将是nl而不是ln Thank you for any comments. 谢谢你的任何评论。

It's historic. 这是历史性的。

Pascal had write and writeln . 帕斯卡尔曾writewriteln

write would output a string, leaving the cursor at the end of that string. write会输出一个字符串,将光标留在该字符串的末尾。

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. writeln (其中ln是“line”的缩写)将write整行文本并将光标移动到下一行开头 ,通常是通过自动附加CRLF或其他一些依赖于OS的控制序列。

Java inherited the abbreviation, but used print instead of write . Java继承了缩写,但使用print而不是write

Hi check if this is helpful.. 嗨检查这是否有用..

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

You can find it under the heading Class PrintStream 您可以在标题Class PrintStream下找到它

ln simply means LINE - it prints the character/string in a NEW LINE. ln只是意味着LINE -它打印在一个新行的字符/字符串。

println stands for printline. println代表printline。

There is nothing special about it :P It will print a new line instead of printing it on the same line. 它没有什么特别之处:P它将打印一个新行而不是在同一行上打印它。

println() method Terminates the current line by writing the line separator string. println()方法通过写行分隔符字符串来终止当前行。 The line separator string is defined by the system property line.separator, and is not necessarily a single newline character ('\\n'). 行分隔符字符串由系统属性line.separator定义,不一定是单个换行符('\\ 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) . 此外,还有重载方法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 . http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/io/PrintStream.java#PrintStream.println%28%29

println -> print line. println - >打印行。

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. 这意味着它将通过参数打印您给出的行,并将光标移动到下一行,等待另一个输入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM