Why don't we close `System.out` Stream after using it?

我是研究僧i 提交于 2019-11-28 00:41:07

If you close it you will no longer be able to write to the console, so let's leave this task to the VM when the process terminates. You should only close streams that you own or have manually created. System.out is out of your control, so leave it to the creator to take care of.

ratchet freak

because we didn't open it the VM did and it's his job to close it unless otherwise documented

it's similar to the C++ adage of I don't own it, don't delete it.

You can still flush() it, of course.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!