title: How to format Java ArrayList with respective rows and columns and invoke the data of a column or a row?
body: <p>I am a Java beginner, I have been trying to read a csv file from my computer by using Java and insert the data into a ArrayList.  </p>
  
  <pre><code>public class DataRepository {
  
  public void loadFile(){
      ArrayList&lt;String&gt; binsGrade = new ArrayList&lt;String&gt;();
      try {
          Scanner fileScanner = new Scanner(new File("C:\\Users\\Max\\Desktop\\Grade_SampleData.csv"));
          while(fileScanner.hasNextLine()){
  
              binsGrade.add(fileScanner.nextLine());
          }
  
          fileScanner.close();
  
          System.out.println(binsGrade);
  
  
      } catch (FileNotFoundException e){
          e.printStackTrace();
      }
  }
  }
  </code></pre>
  
  <p>And below is the result I got: </p>
  
  <pre><code>[name,literature,math,physics,chemistry,biology,history,geology,art,sports, Michael,80,90,82,79,75,70,72,68,95, Amy,85,88,73,79,88,93,90,92,75, Johnson,72,89,81,84,83,72,89,90,82, Bob,80,81,84,89,87,90,71,65,89, Tommy,70,89,79,90,88,73,75,89,91, Rachel,90,91,80,92,87,92,95,97,87, Evonne,78,91,87,88,91,76,74,86,91]
  </code></pre>
  
  <p>All the records are in one row, but I actually want it to be in separated rows and columns, and for example, when I call name, I can get the value: Michael, Amy, Johson and etc. When I call literature, I can get 80, 85, 72, 80 and etc.Then I can probably use these data to do some calculation, like calculate the average, or get the maximum score and etc. </p>
  
  <p>Although I have been searching online for a while, I still have not figured out the best way to achieve this. Can you please share your ideas if you have one minute? Your help will be really appreciated. Thanks!</p>