title: How to get Max and Min values from CSV file in Java
body: <p>Here is my CSV file: marks.csv and it contains with the student number on the left and the marks on the right:</p>
  <pre><code>B00123,55
  B00783,35
  B00898,67
  </code></pre>
  <p>I need to be able to search through this file and find the maximum mark and the minimum mark. I have this code that returns the values but I don't know what to do afterwards:</p>
  <pre><code>public static void MaxAndMin()
  {
    // .csv files are comma separated
    String fileName = &quot;src\\data\\marks.csv&quot;;
    File file = new File(fileName);
    
    try 
    {
        Scanner inputStream = new Scanner(file);
        
        while(inputStream.hasNext())
        {
            String data = inputStream.next();
            String [] values = data.split(&quot;,&quot;);
            int mark = Integer.parseInt(values[1]);
            System.out.println(mark);      
        }
        
        inputStream.close();
           
    } 
    catch (FileNotFoundException ex) 
    {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
  </code></pre>
  <p>And this returns the following:</p>
  <pre><code> 55
   35
   67
  </code></pre>
  <p>What can I try next?</p>