在项目开发中,查看输出值,简单调试或许会用到System.out.println()方法。但是正式上线项目,切记不要闲来无事写几个System.out.println(),轻则会使性能受影响重则让服务器瘫痪。
直接上代码
<textarea readonly="readonly" name="code" class="Java">
* Prints a String and then terminate the line. This method behaves as
* though it invokes <code>{@link #print(String)}</code> and then
* <code>{@link #println()}</code>.
*
* @param x The <code>String</code> to be printed.
*/
public void println(String x) {
synchronized (this) {
print(x);
newLine();
}
}
/** * 如果是一个对象,则会多一句代码String s = String.valueOf(x);
* Prints an Object and then terminate the line. This method calls
* at first String.valueOf(x) to get the printed object's string value,
* then behaves as
* though it invokes <code>{@link #print(String)}</code> and then
* <code>{@link #println()}</code>.
*
* @param x The <code>Object</code> to be printed.
*/
public void println(Object x) {
String s = String.valueOf(x);