小编Ali*_*chi的帖子

为什么我们使用system.out.flush()?

有人可以解释为什么我们会system.out.flush()以更简单的方式使用它们?如果有可能丢失数据,请提供一个示例.如果你在下面的代码中评论它没有任何变化!

class ReverseApp{
    public static void main(String[] args) throws IOException{
    String input, output;
    while(true){

        System.out.print("Enter a string: ");
        System.out.flush();
        input = getString(); // read a string from kbd
        if( input.equals("") ) // quit if [Enter]
        break;
        // make a Reverser
        Reverser theReverser = new Reverser(input);
        output = theReverser.doRev(); // use it
        System.out.println("Reversed: " + output);

   }
   }
}
Run Code Online (Sandbox Code Playgroud)

谢谢

java system.out

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×1

system.out ×1