任何一個可以解釋到底是什麼意思如下::什麼是「的System.out.println()」的Java中的確切含義
System.out.println()
我知道:
系統:是一類
我不知道 「出」
println
:靜態方法。
任何一個可以解釋到底是什麼意思如下::什麼是「的System.out.println()」的Java中的確切含義
System.out.println()
我知道:
系統:是一類
我不知道 「出」
println
:靜態方法。
out
是一個靜態字段,其中包含對象的引用PrintStream
對象。
println
不是一種靜態方法。
這裏是out
變量的System.java
/**
* The "standard" output stream. This stream is already
* open and ready to accept output data. Typically this stream
* corresponds to display output or another output destination
* specified by the host environment or user.
* <p>
* For simple stand-alone Java applications, a typical way to write
* a line of output data is:
* <blockquote><pre>
* System.out.println(data)
* </pre></blockquote>
* <p>
* See the <code>println</code> methods in class <code>PrintStream</code>.
*
* @see java.io.PrintStream#println()
* @see java.io.PrintStream#println(boolean)
* @see java.io.PrintStream#println(char)
* @see java.io.PrintStream#println(char[])
* @see java.io.PrintStream#println(double)
* @see java.io.PrintStream#println(float)
* @see java.io.PrintStream#println(int)
* @see java.io.PrintStream#println(long)
* @see java.io.PrintStream#println(java.lang.Object)
* @see java.io.PrintStream#println(java.lang.String)
*/
public final static PrintStream out = nullPrintStream();
聲明這是println
方法的樣子:
/**
* Terminates the current line by writing the line separator string. The
* line separator string is defined by the system property
* <code>line.separator</code>, and is not necessarily a single newline
* character (<code>'\n'</code>).
*/
public void println() {
newLine();
}
出是系統的靜態字段,PrintStream類的:
http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/System.html
「out」是具有Stream值的靜態公共字段。
public final class System {
public final static PrintStream out = nullPrintStream();
...
}
out
是類型爲PrintStream
的靜態字段。閱讀here
System
是一類。 out
是System
類的靜態字段,其類型爲PrintStream
。 println
是PrintStream
類的實例方法。
只要看看the javadoc,你就會得到你要找的所有信息。
System.out.println()
System
是一個內置類存在於java.lang
包。 該類有一個final修飾符,這意味着它不能被其他類繼承。 它包含預定義的方法和字段,其提供設施,如標準輸入,輸出等
out
是靜態最終字段(即,可變的)在系統類,這是該類型PrintStream
(的內置類,包含打印不同數據值的方法)。 必須使用類名來訪問靜態字段和方法,所以(System.out
)。
out
這裏表示PrintStream
類型的參考變量。
println()
是用於打印數據值的PrintStream
類中的公共方法。
int i = 3;
System.out.println(i);
上面的代碼打印值: 因此訪問方法在PrintStream的類中,我們使用out.println()
例如(作爲非靜態方法和字段只能通過使用參考變量被訪問)在屏幕上顯示3,並將控制權交給下一行。
[類似的問題1](http://stackoverflow.com /問題/ 3406703 /最新-的含義-的系統中取的println合的java/11202369#11202369), [類似問題2](http://stackoverflow.com/questions/10004856/just-wondering -System中取調用println/11202355#11202355) – 2012-06-26 09:28:19
問:要找到S的長度在給定的代碼,你有什麼替代答案就寫?
class Test{
static String S="java";
public static void main(String[] args) {
System.out.println(Ans);
}
}
Ans: Test.S.length()
在此,S爲存在於試驗類
所以String類型的靜態變量,靜態變量是使用class_name.static_variable_name作爲Test.S
要查找長度訪問靜態變量S的,長度()方法用於String類的,其中S是一個對象,我們知道對象可以訪問方法S.length()
相同的概念在的System.out.println()用作:
class System{
static PrintStream out;
}
系統是CLASS_NAME
出存在於系統類類型PrintStream的靜態變量。它也是同一類的PrintStream類和訪問方法println()的對象。
參見文檔:http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/System.html – Cemre 2012-01-12 09:59:39