I tried searching for a similar issue, to no avail. If I change the operator from "!=" to "==", it prints "{ }". Also, if I simply print out the variable I'm testing (current.myData) the Integer that it references prints out as expected. However, every time I test "current.myData != null" it throws a null pointer exception and exits. Any help is greatly appreciated!
public class LinkedQueue<E> implements QueueADT<E> {
@Override
public String toString() {
...
String exitVal = null;
final StringBuffer sb = new StringBuffer();
if (myFront.myData == null) {
exitVal = "{ }";
} else {
Node<E> current = myFront.myNext;
sb.append('{');
sb.append(myFront.myData);
while (current.myData != null) {
sb.append(", ");
sb.append(String.valueOf(current.myData));
current = current.myNext;
}
sb.append('}');
exitVal = sb.toString();
}
return exitVal;
}