zoukankan      html  css  js  c++  java
  • System.err.println输出位置不唯一确定

    public static void main(String[] args) {
            int x=1;
            System.out.println("Before the loop");
            
            while (x<4) {
                System.err.println("in the loop");
                //System.out.println("in the loop");
                System.out.println("Vlaue of x is "+x);
                x=x+1;
            }
            
            System.out.println("after the loop");
                    
        }

      根据代码执行顺序,应该得出这样的结果:

    Before the loop
    in the loop
    Vlaue of x is 1
    in the loop
    Vlaue of x is 2
    in the loop
    Vlaue of x is 3
    after the loop

    但是,实际的运行结果:

     

     

    System.out在JVM和操作系统都具有缓存功能,

    就是你输出的东西不一定实时输出,有时候会积攒到一定数量才会输出

    System.err实时输出(默认设置,可以改)

    这也是为什么err打印位置不固定的原因

  • 相关阅读:
    hdu2151
    hdu1028
    hdu1398
    hdu1465
    hdu2853
    poj2195
    poj2255
    JS正则校验数字,特殊字符,邮箱基本格式
    JS正则校验数字,特殊字符,邮箱基本格式
    io读取文件内容乱码处理
  • 原文地址:https://www.cnblogs.com/panghao/p/14374325.html
Copyright © 2011-2022 走看看