[Solved] Output accumulates each iteration instead of resetting [closed]


You’re reusing the same string buffer. If you keep putting things into the same buffer without clearing it, you’re obviously going to get extraneous stuff from previous iterations.

Simply declare the StringBuffer inside the while loop so that it is created on each iteration.

Anyway, you should learn to use your debugger, instead of asking here for us to debug. If anything, using the debugger can offer extremely valuable insight into the troubles that you are having here.

16

solved Output accumulates each iteration instead of resetting [closed]