| Author |
array declaration and creation
|
Alangudi Balaji Navaneethan
Ranch Hand
Joined: Apr 28, 2004
Posts: 42
|
|
Hi, I have a doubt in the following code. Please clear my doubt Upto line 3 I have no problem. I well understood the concept behind them. The compiler generated error messages at line 4 and line 5 saying illegal start of expression.
|
 |
vidya sagar
Ranch Hand
Joined: Mar 02, 2005
Posts: 580
|
|
array2[0] = {1,2,3,4,5}; // line 4 array2[1] = {6,7,8,9,10}; // line 5
array2 is a Two dimensional array array2[0] - holds only address of a one dimensional array or null array2[0][0] - holds only values but in the above case you are assigning values where it is expecting address changte it to array2[0][0] = {1,2,3,4,5}; // line 4 array2[0][1] = {6,7,8,9,10}; // line 5
|
 |
shyam ramineni
Ranch Hand
Joined: Jul 08, 2005
Posts: 43
|
|
Hi Vidya,
array2[0][0] = {1,2,3,4,5}; // line 4 array2[0][1] = {6,7,8,9,10}; // line 5 --------------------
The above code change you have suggested did not work. Below is the code that works. But I donot know the reason behind it. When we are creating anynomous array and assign that reference to array2[0] its working. Can anyone please tell what differnce between line1 and line2, and when to use which one. int[] a1 = {1,1,1,1}; //line1 int[] a1 = new int[] {1,1,1,1}; // line2 Thanks Shyam Ramineni
|
<a href="http://hyderabaditeducation.com" target="_blank" rel="nofollow">http://hyderabaditeducation.com</a>
|
 |
Georgy Bolyuba
Ranch Hand
Joined: Feb 18, 2005
Posts: 162
|
|
Hi You can read this or this for more information. [ August 05, 2005: Message edited by: George Bolyuba ]
|
SCJP 1.4 (100%) Done.<br />SCJD (URLyBird 1.2.3 Started)
|
 |
 |
|
|
subject: array declaration and creation
|
|
|