Ask your own question, for FREE!
Computer Science 25 Online
OpenStudy (anonymous):

I ran into an error while making a toString method for a linked list of 'a' to 'z'. The result String returned back to the public method only contains 'a' when the result println shows a-z public String toString() { String result = "{"; result = generateList(result, first); result += "}"; return result; } private String generateList(String result, Node first) { result += "," + first.data; System.out.println(result); //tests what result contains at each iteration if(first.next != null) { generateList(result, first.next); } ret

OpenStudy (anonymous):

last part is "return result;" I think the fix to this is to put the return statement of the private method in an else statement, but this results in an error.

OpenStudy (anonymous):

It appears result = generateList(); works..

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!