• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error: found int but expected Movie  RSS feed

 
Lisa Beglaw
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The purpose of this code is to search the collection looking for movies that have never been rented, and then moving them to a new ArrayList and then returning that ArrayList.



Not sure if this is enough code to be able to help me but...

I am getting an error on highlighing the "Movie timesRented = currentMovie.getTimesRented();" line that says found int but expected Movie.

I understand the error is telling me incompatible data types....what I don't understand is where.

Thanks
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lisa Beglaw:



That line looks fishy to me. Your variable, timesRented, seems like it should be an int, not a reference to a Movie object.
 
Saeed Amer
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I am not wrong, "currentMovie.getTimesRented()" is intended to return an "int" not a Movie object. Maybe that is what the error message is trying to tell.

Saeed
[ August 09, 2005: Message edited by: Saeed Amer ]
 
Lisa Beglaw
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you both.

I understand what you are saying...now how do I fix.

I am using a sample from my text to assist me and in the sample they have:



So do I want to change Movie to something that is an int?
 
Saeed Amer
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
replace
-> Movie timesRented = currentMovie.getTimesRented();
with
-> int timesRented = currentMovie.getTimesRented();

and try!

Actually, you should define "timesRenter" outside the "while" loop and then use it like this:
-> int timesRenter;
-> while...
-> ...
-> timesRented = currentMovie.getTimesRented();
-> ...

Hope this helps!
Saeed
 
Lisa Beglaw
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Saeed, I will give that a try!
 
Saeed Amer
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did it go Lisa? Just curious!

Regards,
Saeed
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!