my ToString method to return elements in a queue does not compile. help

basically my ToString method to return elements in a queue from first to last does not compile and i cannot figure out why. it came right out of the book i am reading and i have checked everything. any ideas?

//--------------
// Returns a string containing the elements of the queue
// from first to last
//--------------
public String toString()
{
String result = "\n";
for (int i = front, count=0; count < numElements; i=(i+1)%elements.length,count++)
result = result elements[i]+ "\n";
return result;

}
[610 byte] By [dalearyous] at [2007-11-20 11:32:24]
# 1 Re: my ToString method to return elements in a queue does not compile. help
Perhaps if you posted the error message you get, we might get a clue...

Never put off until run time what can be done at compile time...
A. Glew
dlorde at 2007-11-10 2:14:05 >
# 2 Re: my ToString method to return elements in a queue does not compile. help
i was able to piece together a working tostring method:

public String toString()
{
StringBuffer sb = new StringBuffer();
sb.append('[');
int i = front;
for (int count = 0; count < numElements; count++) {
sb.append(theQueue[i]);
i++;
if (i == theQueue.length)
i = 0;
if (count < numElements - 1)
sb.append(", ");
}
sb.append(']');
return sb.toString();
}
dalearyous at 2007-11-10 2:15:05 >