This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes arraylist problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "arraylist problem" Watch "arraylist problem" New topic
Author

arraylist problem

sam jones
Greenhorn

Joined: Aug 09, 2008
Posts: 5
hello there im just starting java and really programming in general, but i am going through the head first java book, and i am having trouble with one of the exercises, i have spent at least an hour typing and retyping this code and checking it against the book, but i cannot find whats causing the error, this is the exact code i am using(below) and it return this error every time i try and compile it:



any advice on how to fix this would be much appreciated, thank you

Edit: Sorry, did not think about the copyright issue (code deleted)
[ August 09, 2008: Message edited by: sam ]
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

You have a method with a signature of:

And you use this code to call it:


Like the error says, you can't call a method that expects an ArrayList of Strings and pass it an array of ints.

So what does the book have to say about this code? What do you think you can do to resolve this?


Steve
Alex Barfoot
Greenhorn

Joined: Aug 09, 2008
Posts: 3
Here you are trying to call the setLocationCells method giving an int array as the needed parameter when the method setLocationCells only takes ArrayList<String>

I have the book ill go look at the code and see what you done wrong.

Edit found the problem:
The first class you have there is for the first simple dot com game the book does before you learn about Arraylists the second class comes from the full game which the book does after that. You are simple mixing the classes up.
Also the code in the book is copyright protected so you are not supposed to post it on the forum.


[ August 09, 2008: Message edited by: alex barfoot ]
[ August 09, 2008: Message edited by: alex barfoot ]
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1358
    
  17
Hi redbeard,

Please check your private messages for an important administrative message from the staff.

Thanks,
Katrina
JavaRanch Saloon Bartender
sam jones
Greenhorn

Joined: Aug 09, 2008
Posts: 5
alright sorry about that just did not think they would give that code and not tell you need to edit more code to make it work, i did think about the fact that we had an int array trying to be fed into a String arraylist, i just assumed you could read an array into an arraylist of the same type so i tried changing the arraylist to type int, and that's as far as i got, thanks a lot for the help though
[ August 09, 2008: Message edited by: sam ]
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1358
    
  17
Hi there, Sam,

Would you please take the time to read the JavaRanch Naming Policy and change your display name to match?

Thanks,
Katrina
Saloon Bartender
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: arraylist problem