title: How to create multiple arrays from one text line?
body: <p>I'm a first year programming student, so forgive me if this is a dumb question.</p>
  
  <p>What I'm trying to do is read a text file that contains an answer key on line 1, and the proceeding lines will contain a student's ID number and their answers to a test. Here is an example: </p>
  
  <pre><code>TFFTFFTTTTFFTFTFTFTT
  ABC54301 TFTFTFTTTTF TFTFTFTT
  ABC54302 TFFTFFFFFFFFTFTFTFTT
  ABC54303 TFFTFFTTTTFFTFTTTTTT
  ABC54304 TFFTTTFFTTFFTFTFTFTT
  ABC54305 TFTFTFTTTTFFTFTFTFTT
  </code></pre>
  
  <p>My idea is to create three arrays - one that contains only the answer key, one that contains the students' ID numbers, and one that contains the studentss answers. The student ID number is always 8 digits long, but can possibly contain spaces. The student's answers are always 20 characters long, but can also contain spaces. So I can't split them based on spaces. </p>
  
  <p>The instructions contained this:</p>
  
  <pre><code> while (inFile.hasNext())
   {
     ...
   }
  
  where 'inFile' is the Scanner object connected to the input file.
  
  Each student's record should be read by two read's -- 
  one string (for ID) and another string (answer string).
  </code></pre>
  
  <p>I'm pretty lost. My initial idea is to loop through each line past the first, and set each segment of the line to its complimentary array. The problem that I'm reaching is that I can't seem to find any instruction or clarification on how I would split the lines based on number of characters. </p>
  
  <p>I was thinking maybe something like:</p>
  
  <pre><code> while (inFile.hasNext())
   {
      // I would somehow set the first line to its own array
      // As the loop continues, as long as its not the first line
      idNums[i] =     //Characters 1-8
      studentAnswers[i] =     //Characters 10-30
   }
  </code></pre>
  
  <p>Is that reasonable? Or is there an easier way? I feel like I'm approaching this in a manner more complicated than is necessary.</p>
  
  <p>EDIT:</p>
  
  <p>After learning more about maps and regex, I've attempted several different versions of this code. The first consisted of:</p>
  
  <pre><code>while (scan.hasNextLine()) {
      String[] studentInfo = scan.nextLine().split(" ", 2);
      info.put(studentInfo[0], studentInfo[1]);
  }
  </code></pre>
  
  <p>Which kind of worked, but the problem is that if it ended with spaces, it wouldn't save the full 20 characters. Is that an issue? I'm not sure. Currently I'm testing this:</p>
  
  <pre><code>String[] answerKey = scan.nextLine().split("");
  
  Map&lt;String, String[]&gt; results = new HashMap&lt;&gt;();
  while (scan.hasNextLine()) {
      String line = scan.nextLine();
      results.put(line.substring(0, 8), line.substring(9).split(""));
  }
  </code></pre>
  
  <p>Which is giving me the correct keys, but incorrect values. The values seem to be pointing to memory locations. For example:</p>
  
  <pre><code>{ABC54339=[Ljava.lang.String;@55f96302
  </code></pre>