I am tasked with creating a program to list the grades of students that is entered then find the average, highest mark, lowest mark and then list how many students are a level 0, 1, 2, 3 and 4. I have all the other parts done except the last part. All of the marks are entered into an arrayList and then are sorted.
How do I access all of the elements of the arrayList one after the other so that all of the marks are entered into the correct category? Here is what I have so far (I already initialized the arrayList within the package, and I know that the get statement at the end isn't finished, that's what I need help with):
EDIT: I figured that i should add that the categories that i wish each element be sorted into is an array, so I will have to at some point return five arrays.
public U3A6_Marks_WillCampbellUI() {
    initComponents();
}
ArrayList <Integer> marks = new ArrayList();
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    Collections.addAll(marks, Integer.parseInt(jTextField3.getText()));
    StringBuilder text = new StringBuilder();
    for (Integer mark: marks) {
        text.append(mark.toString()).append('\n');
}
    jTextArea1.setText(text.toString());
    jTextField3.setText("");
}                                        
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    Collections.sort(marks);
    StringBuilder text = new StringBuilder();
    for (Integer mark: marks) {
        text.append(mark.toString()).append('\n');
}
    jTextArea1.setText(text.toString());
}                                        
/**
 * @param args the command line arguments
 */
private double average(List <Integer> marks) {
    Integer sum = 0;
    if(!marks.isEmpty()) {
    for (Integer mark : marks) {
         sum += mark;
}
 return sum.doubleValue() / marks.size();
}
 return sum;
}
private int highest(int[] marks) {
     int largest = marks[0];  
     for(int i = 1; i < marks.length; i++){  
     if(marks[i] > largest){  
          largest = marks[i];  
    }  
}  
    return largest;
}
private int lowest(int[] marks) {
    int smallest = marks[0];
    for(int i = 0; i > marks.length; i++) {
        if(marks[i] < smallest){
            smallest = marks[i];
        }
    }
    return smallest;
}
private int sorted() {
    int a = marks.get();
}
 
    