[Bluej-discuss] Please help - cannot resolve symbol - exercise 2.74

Michael Kölling M.Kolling at kent.ac.uk
Sun Oct 8 18:10:06 BST 2006


Hi Dominic,

It helps being a bit more precise: when exactly do you get the error  
-- when you compile, or when you are trying to invoke a method?

I am guessing that it is on invocation. If that is the case, then the  
most likely problem is that you wrote the author's name without  
double-quotes. The name is a Sting, and Strings in Java are always  
written with double-quotes. That is, write

     "Shakespeare"

rather than

     Shakespeare

Regards,

Michael




On 8 Oct 2006, at 16:50, dominic.smith wrote:

> Hi list
>
> I am about 10 hours into learning java. I have been working through
> chapter 2 of the evaluation pdf's (I have ordered the book, but i am
> still waiting for it, amazon...)
>
> I hit a bit of stumbling block on exercise 2.74 when working on an  
> class
> exercise that involves adding 2 accessor methods that return author  
> and
> title fields.
>
> i keep getting an error saying it cannot resolve the symbol (author  
> name
> I enter etc).
>
> No doubt I have made a very obvious school boy error. Please help,  
> even
> cryptic hints would be good.
>
> dominic
>
>
> Code:
> ______________________________________________________________________ 
> __
>  class Book
> {
>     // The fields.
>     private String author;
>     private String title;
>
>     /**
>      * Set the author and title fields when this object
>      * is constructed.
>      */
>     public Book(String bookAuthor, String bookTitle)
>     {
>         author = bookAuthor;
>         title = bookTitle;
>     }
>
>     // Add the methods here ...
>
>     public String getAuthor()
>     {
>         return author;
>     }
>
>     public String getTitle()
>     {
>         return title;
>     }
> //commented the following out as it did not seem to help!
> // public void setBook(String bookAuthor, String bookTitle)
>     //{
>         //author=bookAuthor;
>         //title=bookTitle;
>     //}
>
>
>
>
>
> _______________________________________________
> mailing list bluej-discuss at bluej.org
> To unsubscribe or change your preferences, go to
> http://lists.bluej.org/mailman/listinfo/bluej-discuss



More information about the bluej-discuss mailing list