System.out.println()的详解

Posted stujike

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了System.out.println()的详解相关的知识,希望对你有一定的参考价值。

System是System类

1 package java.lang;
2 public final class System {
3       public final static PrintStream out = null;
4 }

println()是PrintStream 类中的方法。

package java.io;
public class PrintStream extends FilterOutputStream
    implements Appendable, Closeable
{
  
   protected OutputStream out;

   private BufferedWriter textOut;

    private void ensureOpen() throws IOException {
       if (out == null)
        throw new IOException("Stream closed");
    }

   
public void println() { newLine();//换行 } public void println(boolean x) { synchronized (this) { print(x); newLine(); } } public void println(String x) { synchronized (this) { print(x); newLine(); } } public void print(boolean b) { write(b ? "true" : "false"); } public void print(Object obj) { write(String.valueOf(obj)); } private void write(String s) { try { synchronized (this) { ensureOpen(); textOut.write(s); textOut.flushBuffer(); charOut.flushBuffer(); if (autoFlush && (s.indexOf(‘ ‘) >= 0)) out.flush(); } } catch (InterruptedIOException x) { Thread.currentThread().interrupt(); } catch (IOException x) { trouble = true; } } private void newLine() { try { synchronized (this) { ensureOpen(); textOut.newLine(); textOut.flushBuffer(); charOut.flushBuffer(); if (autoFlush) out.flush(); } } catch (InterruptedIOException x) { Thread.currentThread().interrupt(); } catch (IOException x) { trouble = true; } } }

 









以上是关于System.out.println()的详解的主要内容,如果未能解决你的问题,请参考以下文章

System.out.println()详解 和 HttpServletRequest 和 XMLHttpRequest

java字符串的替换replacereplaceAllreplaceFirst的区别详解

Scala 模式匹配详解

Scala 模式匹配详解

String intern()方法详解

Java 算术运算符/,%,++的本质详解