Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Unknown Source) at java.lang.AbstractStringBuilder.expandCapacity(Unknown Source) at java.lang.AbstractStringBuilder.append(Unknown Source) at java.lang.StringBuffer.append(Unknown Source) at LinkedList.toString(class and line) // see below at AddressBook.main(class and line) //I took this out for reasons I don't want to discuss but it shouldn't matter
public String toString() {
LinkedNode<E> node = head;
StringBuffer str = new StringBuffer();
while (node != null){
str.append(node.key.toString() + " ");
str.append(node.item.toString());
node = node.next;
}
return str.toString();
}
Is there a memory leak or something? Most of the code in this program I referenced from my instructor, and the example he gave us is really similar to our assignment, just that our nodes have to store a "key" string in addition to an "item" string. I've googled my fingers to the bone trying to search for more examples of overridden toString methods and couldn't find anything. Hopefully someone can point me in the right direction. Thanks in advance.
This post has been edited by mistamutt: 07 February 2011 - 08:53 PM

New Topic/Question
Reply




MultiQuote




|