Write a method called toString that returns a string representation of the list, such as "[5, -2, 9]" .
Add the above method to the LinkedIntList class from this chapter.
Implementation of toString method:
public String toString()
{
String str = "[";
ListNode current = front;
while(current != null)
{
str += current.data;
if(current.next != null)
{
str += ", ";
}
current = current.next;
}
str += "]";
return str;
}