title: java.lang.String cannot be cast to java.util.Map
body: <p>I'm new to Java, but not new to programming, so as my first project I decided to create a .txt-.csv parser for someone at work. I read each line in the .txt file and separate it into separate Maps for sections, subsections, subsubsections, and the subsubsections' contents. Each Map is then assigned to the Map above it (more on this below). I print everything to it just fine, but when I try to read it I get the following error: <code>"java.lang.String cannot be cast to java.util.Map"</code>. The error only appears after the code is run, not while compiling, nor in NetBeans IDE.</p>
  
  <p>My Maps are in the following form with each Object being the Map below it: (Why can't Java make this easy -_- Associative Arrays are all I want)</p>
  
  <pre><code>(Map)array=&lt;string,Object&gt;
  (Map)subarray=&lt;String,Object&gt;
  (Map)subsubarray=&lt;String,Object&gt;
  (Map)subsubcontents=&lt;String,String&gt;
  </code></pre>
  
  <p>May not be the most efficient way to read this, plan on converting this to recursive function later, but here is my code, copy-pasted from my project. I put comments at where I've found the error to be.</p>
  
  <pre><code>public static Map&lt;String,Object&gt; array=new HashMap&lt;String,Object&gt;();
  
  /* Code for populating the following Maps and pushing them into array
  &lt;String,Object&gt;subarray
  &lt;String,Object&gt;subsubarray
  &lt;String,String&gt;subsubcontents
  */
  
  Set section=array.entrySet();
  Iterator sectionI=section.iterator();
  while(sectionI.hasNext()) {
      Map.Entry sectionInfo=(Map.Entry)sectionI.next();
      Map&lt;String,Object&gt; subMap=(Map)sectionInfo.getValue();
      Set subSet=subMap.entrySet();
      Iterator subI=subSet.iterator();
      while(subI.hasNext()) {
              Map.Entry subInfo=(Map.Entry)subI.next();
              Map&lt;String,Object&gt; subsubMap=(Map)subInfo.getValue();
              Set subsubSet=subsubMap.entrySet();
              Iterator subsubI=subsubSet.iterator();
              while(subsubI.hasNext()) {
                      System.out.println("test");
                      Map.Entry subsubInfo=(Map.Entry)subsubI.next();
                      Map&lt;String,Object&gt; subcontentsMap=(Map)subsubInfo.getValue();
  /*
  The above line seems to be causing the issues.
  If you comment out the rest of this loop (below this comment)
  the error will still appear. If you comment out the rest of this loop
  (including the line above this comment) it disappears.
  Power of deduction my dear Watson.
  */
                      Set subcontentsSet=subcontentsMap.entrySet();
                      Iterator keys=subcontentsSet.iterator();
                      while(keys.hasNext()) {
                          Map.Entry keyMap=(Map.Entry)keys.next();
                      }
                      Iterator values=subcontentsSet.iterator();
                      while(values.hasNext()) {
                          Map.Entry valueMap=(Map.Entry)values.next();
                      }
              }
      }
  }
  </code></pre>
  
  <p>Any help would be much appreciated. I've been struggling with this for a couple of days now.</p>