programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Tim Cooke
• Devaka Cooray
• Ron McLeod
• Jeanne Boyarsky
Sheriffs:
• Liutauras Vilda
• paul wheaton
• Junilu Lacar
Saloon Keepers:
• Tim Moores
• Stephan van Hulst
• Piet Souris
• Carey Brown
• Tim Holloway
Bartenders:
• Martijn Verburg
• Frits Walraven
• Himai Minh

# Arrays

Greenhorn
Posts: 10
• Number of slices to send:
Optional 'thank-you' note:

Output
arr.java:4: incompatible types
found : int[]
required: int[][]
b = a;
^
1 error

Ranch Hand
Posts: 448
• Number of slices to send:
Optional 'thank-you' note:
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.

Bartender
Posts: 3225
34
• Number of slices to send:
Optional 'thank-you' note:
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'.

Ranch Hand
Posts: 173
• Number of slices to send:
Optional 'thank-you' note:
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
Posts: 10
• Number of slices to send:
Optional 'thank-you' note:
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