*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Arrays" Watch "Arrays" New topic
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: 448

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....


Java Experience
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Arrays
 
Similar Threads
Cannot Open Excel file in Browser. + JSF + JSP + Bean
Two D array
array declaration
Array Issue
Explain this code about Arrays