title: Displaying Stats with arrays in Java
body: <p>I am trying to display statistics from a simple text file using arrays in Java. I know what I am supposed to do, but I don't really how how to code it. So can anybody show me a sample code on how to do it.</p>
  
  <p>So let's say the text file is called gameranking.txt, that contains the following information (This is a simple txt file to use as an example):</p>
  
  <pre><code>Game Event, 1st place, second place, third place, fourth place
  World of Warcraft, John, Michael, Bill, Chris
  Call of Duty, Michael, Chris, John, Bill
  League of Legends, John, Chris, Bill, Michael. 
  </code></pre>
  
  <p>My goal is to display stats such as how many first places, second places.. each individual won in a table like the following</p>
  
  <pre><code>Placement     First place, second, third, fourth
  John            2            0       1      0
  Chris           0            2       0      1
  etc...       
  </code></pre>
  
  <p>My thought:<br>
  First, I would read the gameranking.txt and stores it to "input". Then I can use the while loop to read each line and store each line into a string called "line", afterward, I would use the array method "split" to pull out each string and store them into individual array. Afterward, I would count which placement each individual won and display them into a neat table using printf. </p>
  
  <p>My first problem is I don't know how to create the arrays for this data. Do I first need to read through the file and see how many strings are in each row and column, then create the array table accordingly? Or can I store each string in an array as I read them? </p>
  
  <p>The pseudocode that I have right now is the following.</p>
  
  <ul>
  <li>Count how many rows are there and store it in row</li>
  <li>Count how many column are there and store it in column</li>
  <li>Create an array</li>
  <li><code>String [] [] gameranking = new String [row] [column]</code></li>
  <li>Next read the text file and store the info into the arrays</li>
  </ul>
  
  <p>using:</p>
  
  <pre><code>while (input.hasNextLine) {
      String line = input.nextLine();
      while (line.hasNext()) {
          Use line.split to pull out each string
          first string = event and store it into the array
          second string = first place
          third string =......
  </code></pre>
  
  <ul>
  <li>Somewhere in the code, I need to count the placement....</li>
  </ul>
  
  <p>Can somebody please show me how I should go about doing this? </p>