Java Issue

Soldato
Joined
5 Jul 2005
Posts
17,995
Location
Brighton
Hey, need a bit of help with this error I'm getting.

Code:
  public void study()
    {
        if (TextBook book == null){
           book = bookShelf[ nextBook ]; 
           nextBook++;
           card.swipe();
        } else if (isFinished == false) {
            chaptersRead++;
        } else {
            bookShelf[ nextBook ] = null;
        }

I'm a total beginner and really don't know where to start, when I compile it I get the error ')' expected but can't see any brackets that haven't been closed.

I'm not looking for you to write it for me, maybe just point me in the right direction if possible, thanks for looking :)
 
Last edited:
'book' is a variable in the class Textbook and isFinished is a boolean variable.

It happens at the line;
Code:
if (TextBook book == null){

When you call the method it's supposed to assign a TextBook to the class Student if it doesn't already have one, 'read' a chapter if it does and replace the book in the array bookshelf if it has been finished.

Not sure if it's relevent but I'm using BlueJ.

Again, apologies for being utterly useless at this programming lark :p
 
Back
Top Bottom