2010-11-20 27 views

回答

6

這意味着你使用大括號之間的內容來初始化數組。例如:

new Integer[] { 1, 2, 3} 

使與1,2和3的陣列在另一方面:

new Integer[] {} 

就意味着你沒有任何值初始化數組。所以它與new Integer[0]相同。

3

這實際上意味着空陣列。該{}允許您提供數組的元素:

Integer[] ints = list.toArray(new Integer[]{1, 2, 3}); 

等同於:

Integer[] ints = new Integer[3]; 
ints[0] = 1; 
ints[1] = 2; 
ints[2] = 3; 

檢查此鏈接:

瞭解更多信息 - 去Creating, Initializing, and Accessing an Array部分ñ。

1

是的,一個空的數組。就像Integer [0]。