Thursday 15 April 2010

java - LinkedList Iterator next() throwing NoSuchElementException even when called after hasNext() returning true -


Linkedist Arturizer Next () to throw NoSuchElementException also when the truth is called after the nested (), the truth is coming back. / P> A freeware, believe that it is irrelevant to release while (lines.hasNext ()) {int i = 0; Do {writer.write (lines.next ()); Writer.newLine (); I ++; } While (lines hasNext () & i & lt; targetLineCount); // some more code ...}

Updates with more code

  public class MyClass {// only one Example This class is used in the private list & lt; String & gt; Master = new linked list & lt; String & gt; (); // This example behaves the public MyClass to tune other example members (// Source and amp; Populate Master) Public Boolean Writing Data Slot (Writer Writer, Intimate LiveCount) {// It can be written by various thread illustrators ; String & gt; line = master.Director (); while (lines.hasNext ()) {int i = 0; do {writer.write (lines.next ()); writer.newLine (); i ++; } While (lines haveNext () & amp; i & lt; targetLineCount; // something else to populate slots from different sources Code.}}}}    

Axel reported that a threading seems like a problem .

/ div>

No comments:

Post a Comment