Originally posted by Simon Cockayne:
Hi, .....
B) int[] x = {1,2}; // Creates new aray object, referenced by x AND specifies values of x[0]==1 & x[1]==2.
But, why allow:
C) int[] x = new int[]{1,2};
What is this doing over and above B)?
I don't think it's doing anything over and above B. B is just a shortcut version of C. Note that the right side of C does have value, though, like when you want to create an array on-the-fly to, f.e., pass into a method. See the second half of chap. 1 in the S&B book.