title: Serializing a List<List<String>> infinite loop iterator.hasNext() JAVA
body: <p>I've been trying to serialize a <code>List&lt;List&lt; String &gt;&gt;</code> in Java but my code gets stucks in a loop. Here's the code:</p>
  <pre><code> public void Serializing(List&lt;List&lt;String&gt;&gt; player,File file ) throws IOException{
          
          try {
              fileOut=new FileOutputStream(file);
              out= new ObjectOutputStream(fileOut);
              Iterator &lt;List &lt;String&gt;&gt; it=player.listIterator();
            while(it.hasNext()){ //Somehow if i don't put this just adds my first element 
                out.writeObject(player.listIterator().next());
              }
              fileOut.close();
              out.close();
              
          } catch (FileNotFoundException ex) {
              Logger.getLogger(ManejoInformacion.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
  
  </code></pre>
  <p>I'm adding the deserializable method just in case</p>
  <pre><code>public  List&lt;List&lt;String&gt;&gt; deserializable(File file) throws FileNotFoundException, IOException, ClassNotFoundException{
          ObjectInputStream in;
          List&lt;List&lt;String&gt;&gt; info;
          try (FileInputStream fileIn = new FileInputStream(file)) {
              in =new ObjectInputStream(fileIn);
              info = new ArrayList&lt;&gt;();
              info =(List&lt;List&lt;String&gt;&gt;)in.readObject();
           }      in.close();
          return info;
      }
  
  </code></pre>
  <p>Hope this is enough! Thank you :)</p>