• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Missing a ')' somewhere...

 
Lisa Beglaw
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I keep getting an error ')' missing and highlighting the first System.out line. But that line seems fine as do the ones above it.

Is a missing bracket the ACTUAL problem?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if (currentMovie.getCurrentlyRented() = true) {

Should be

if (currentMovie.getCurrentlyRented() == true) {

but if you instead used the preferred

if (currentMovie.getCurrentlyRented()) {

this wouldn't have happened!
 
Lisa Beglaw
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you thank you thank you....I thought I was OVER the == errors by now! I thought I had learned my lesson with my last assignment!
 
Lisa Beglaw
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
New question on the same method...when I run the method, I get the comment lines printed twice.

Total number of movies = 2
Of those movies 0 are currently rented out.
Total number of movies = 2
Of those movies 0 are currently rented out.

is what prints out...and I did clear my comments screen just to make sure.

I am assuming it is printing out one line for each movie.

How can I get it to only print out once?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These two lines


System.out.println("Total number of movies = " + movieCollection.size());
System.out.println("Of those movies " + rentedResults + " are currently rented out.");


are inside the loop, so they're executed once for every movie. You need to move them after the loop, so they're only executed after all the statistics are collected.
 
Lisa Beglaw
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again...so simple. Why can I not see these simple little errors?

Thank you again!
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For many of them, a good programmer's editor really helps a lot. You can make things a lot easier on yourself by using even something simple like JPad .
 
Stephen Boston
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find JCreator very helpful on finding errors. (And I make a lot of them! )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic