| Author |
Arrays
|
Vidya sumanasekara
Greenhorn
Joined: Feb 03, 2011
Posts: 10
|
|
Output
arr.java:4: incompatible types
found : int[]
required: int[][]
b = a;
^
1 error
Can any one please help me to understand the output....
|
 |
Sunny Bhandari
Ranch Hand
Joined: Dec 06, 2010
Posts: 446
|
|
Hi Vidya,
I think you overlooked the following line in the code:
I will split it into two lines to make it clear, the meaning will remain same:
You can refer the Array chapter in any good Java book or on the web.
Happy to help you....
|
 |
Mohamed Sanaulla
Bartender
Joined: Sep 08, 2007
Posts: 2927
|
|
In The line
int [] a = null, b [] = null, b is actually declared as int[][]. So you have 2D array 'b' being assigned to a 1D array 'a'.
|
Mohamed Sanaulla | My Blog
|
 |
Hareendra Reddy
Ranch Hand
Joined: Jan 09, 2011
Posts: 173
|
|
Hello Vidya sumanasekara ,
The problem here is this line
Now b is interpreted by compiler as 2-D array i.e b[][] ,
notice that a array if int type and b array of array of ints ..
HTH
|
 |
Vidya sumanasekara
Greenhorn
Joined: Feb 03, 2011
Posts: 10
|
|
int[] a = null , b [] = null; This is same as 1-D a[] and 2-D b[][] is n't it..
Ok..thank you all of you
Hareendra Reddy wrote:Hello Vidya sumanasekara ,
The problem here is this line
Now b is interpreted by compiler as 2-D array i.e b[][] ,
notice that a array if int type and b array of array of ints ..
HTH
|
 |
 |
|
|
subject: Arrays
|
|
|