java中的System.out.write和System.out.print有什么区别
我想知道我的java类教师编译器中System.out.write和System.out.print的区别在哪里让我们在java中学习代码并且不明白,因为它有时使用System.out.write和其他使用System.out.print
PrintStream
的两种方法有不同的含义:
-
print(int)
写入整个int
的十进制表示,而 -
write(int)
将指定int
的最低有效字节写入输出。
这会导致不同的结果:如果调用print(48)
,输出将为48
,但如果调用write(48)
,则输出将取决于系统,但在大多数系统上,它将为0
。
演示。
对我来说,我使用System.out.write()但它没有用,我把它改为println并且它有效。我仍然不明白为什么。