aspose file tools*
The moose likes Beginning Java and the fly likes ArrayList Recursions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayList Recursions" Watch "ArrayList Recursions" New topic
Author

ArrayList Recursions

Mario Martinez
Greenhorn

Joined: Oct 10, 2002
Posts: 12
Why, hello there!
I have a problem you see, I need to use a recursive solution to solve a maze (you've all done that, right? ).
Anyway, the problem I have is the return statement. Here is an example

I have to return an arrayList of rooms that have the solution,
I declared,


I have to return an arrayList with rows and columns. I made an arrayList called Roomsready, that will add the current rooms, and then call the method again to do it again, and thus keep adding the rooms up to the solution.
Thus, with that code, if the NorthWall is open, I am suppose to move to the NorthWall adjacent room, and then check if their a soulution, if their are any open walls their. If not, return to the previous room and check for another wall. South, West, etc.
...Anyone?

Oh, this is my error message:


The arraylist is defined as:



I want to return that arraylist.
[ November 08, 2002: Message edited by: Mario Martinez ]
Ken Cobbs
Greenhorn

Joined: Jun 18, 2002
Posts: 29
I believe you need "import java.util.*; " at the top. Is that the way it is?
Mario Martinez
Greenhorn

Joined: Oct 10, 2002
Posts: 12
Originally posted by Ken Cobbs:
I believe you need "import java.util.*; " at the top. Is that the way it is?

I have that though.
Take a look this though!

solve is the method that will return an arraylist of room addresses, which will be used by another method to draw the solution.
[ November 08, 2002: Message edited by: Mario Martinez ]
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

The error is occurring because startRow is an int. You can't add primitives ( int, long, boolean,floats, etc...) to Lists, you must add an object like an Integer, Boolean, Double, etc.
Jamie
 
Don't get me started about those stupid light bulbs.
 
subject: ArrayList Recursions