简体   繁体   English

显示/打印null值是否会导致NullPointerException

[英]Does displaying/printing a null value cause NullPointerException

Does displaying/printing a null value cause NullPointerException or does only trying to manipulate it? 显示/打印null值是否会导致NullPointerException或仅尝试对其进行操作?

If I had an array A and an array B which was twice the size of A . 如果我有一个数组A和一个数组B ,其大小是A两倍。 If I copied all the elements from A into B using 如果我使用将所有元素从A复制到B

Arrays.copyOf(A, 2*A.length)

When I print B using Arrays.toString(B) , it happily prints out even null values without throwing any exceptions. 当我使用Arrays.toString(B)打印B ,它愉快地打印出了null值,而没有Arrays.toString(B)任何异常。

From docs : Prints a string. 来自docs :打印字符串。 If the argument is null then the string " null " is printed. 如果参数为null,则输出字符串“ null ”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM