Help Please - exam question

I'm having difficulty with the following question for an OU exam:

You will now create a method to enable students to make a list of the books they have read, whether they are on the courses reading list or not.

Add an instance method to the class, with the header: public Set<String> collectBooksRead()

The method should first declare a local variable of type Set called readBooks capable of holding a set of strings.

The method should then assign to that variable an appropriate set object.

The method should then use a dialogue box to collect the book titles one at a time from the user.

The dialogue box should have the prompt "Please input a book title or * to finish", and should have an empty string as its default reply.

Each entered book title should be added to the set referenced by the local variable readBooks. Finally the method should return readBooks as the message answer.

Here's my code so far but it endlessly loops and I'm unsure how to make it stop.

public Set<String> collectBooksRead()

{

Set<String> readBooks = new HashSet<String>();

String title;

{

do

{

title = OUDialog.request("Please input a book title or * to finish",""); //OUDialog.request displays an input dialogue box as specified by a superclass

readBooks.add(title);

}

while

(title != "*");

}

[1432 byte] By [BrianSouthalla] at [2007-11-27 11:05:57]
# 1

!title.equals("*");

radio_circus_radioa at 2007-7-29 13:12:05 > top of Java-index,Java Essentials,Training...
# 2

http://forum.java.sun.com/thread.jspa?threadID=5196761

~

yawmarka at 2007-7-29 13:12:05 > top of Java-index,Java Essentials,Training...
# 3

Don't crosspost.

http://forum.java.sun.com/thread.jspa?threadID=5196761

It's very annoying to answer a question, only to find I've wasted my time repeated what somebody else has already said, or to get into a fragemented discussion that's split across multiple threads.

jverda at 2007-7-29 13:12:05 > top of Java-index,Java Essentials,Training...
# 4

answered now from another forum.

No further replies necessary

BrianSouthalla at 2007-7-29 13:12:05 > top of Java-index,Java Essentials,Training...