本文介绍了out.write()和out.print()之间的确切区别是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的servlet中,我给了 out.print
和 out.write
。但两者都在浏览器中打印。
In my servlet I gave both out.print
and out.write
. but both prints in the browser.
这两者之间的确切差异以及何时使用 out.print
和 out.write
?
What is the exact difference between these two and when to use out.print
and out.write
?
推荐答案
基本区别在于 out.write()
如果你把它传给null就会爆炸:
The basic difference is that out.write()
explodes if you pass it a null:
String s = null;
out.print(s); // outputs the text "null"
out.write(s); // NullPointerException
这篇关于out.write()和out.print()之间的确切区别是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!