• Post Reply Bookmark Topic Watch Topic
  • New Topic

two dimensional array passing to method  RSS feed

 
mark Bau
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI I am new to this forum.

I have a question about an error I am getting when trying to pass a two dimensional array to a method.
I keep getting the "incompatible types, int cannot be converted to int[][]". I am getting the
error in a few different place (see comments - at the first call of the method, at
a recursive call, and at the return statement. I believe I am passing the same
type of array in all cases to the type of array defined in the method parameters.
Any thoughts would be greatly appreciated.

-MAB


Below is my code.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37462
537
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mark Bau wrote: I believe I am passing the same type of array in all cases to the type of array defined in the method parameters.

You actually aren't.


The method takes two 2D arrays as parameters.


When you call it, you are passing two ints. Let's look at why:
a is a 2D array
a[r] is a 1D array
a[r][l] is an int and not an array
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to JavaRanch, mark.

Winston
 
mark Bau
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Jeane,
That made a lot of sense.
Mark
 
mark Bau
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Winston.

Mark
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!