我有一个简单的属性的setter方法,null不适合这个特定的属性.我总是在这种情况下被撕裂:我应该扔一个IllegalArgumentException,还是一个NullPointerException?从javadocs看,两者似乎都合适.有某种理解标准吗?或者这只是你应该做的任何事情之一,而且两者都是正确的?
java null exception nullpointerexception illegalargumentexception
打印char数组不显示哈希码:
class IntChararrayTest{
public static void main(String[] args){
int intArray[] = {0,1,2};
char charArray[] = {'a','b','c'};
System.out.println(intArray);
System.out.println(charArray);
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
[I@19e0bfd
abc
Run Code Online (Sandbox Code Playgroud)
为什么整数数组打印为哈希码而不是char数组?