<分区>
Java PrintWriter
类中的write()
和print()
方法有什么区别?
<分区>
Java PrintWriter
类中的write()
和print()
方法有什么区别?
最佳答案
print() formats the output, while write() just prints the characters it is given. print() handles many argument types, converting them into printable strings of characters with String.valueOf(), while write() just handles single characters, arrays of characters, and strings.
To illustrate the difference, write(int) interprets the argument as a single character to be printed, while print(int) converts the integer into a character string. write(49) prints a "1", while print(49) prints "49".
关于java - Java 中的 PrintWriter write() 与 print() 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30662642/