2013-06-05 33 views

回答

0

您可以指定null任何變量,除了primitive數據類型

String s = null; //true because String is object 
0

字符是值類型,因此它們不能保存引用... null只能分配給引用類型。

char and other primitive datatypes can hold value only. 
a[i] = 'a'; // allowed 
a = null; // allowed 
a[i] = null; // not allowed 


int a = 2; //allowed 
int a = null; // not allowed 

string a = null; //allowed because string array of characters. 
相關問題