Q: Java arrayList comparison Could anybody tell me how to list some data in an arrayList according to the integer value that each component of the ArrayList has? This is my main class
import java.util.Scanner;
import java.io.*;
import java.util.Collections;
import java.util.ArrayList;
public class StudentDriver {

public static void main(String[] args) throws IOException {

    Scanner scan, urlScan, fileScan;
    String url, file;
    int count = 0;
    scan = new Scanner(System.in);
    System.out.println("Enter the name of the file");
    fileScan = new Scanner(new File("Data.csv"));
    ArrayList<Student> studentList = new ArrayList<Student>();
        while(fileScan.hasNext()){
            url = fileScan.nextLine();
            urlScan = new Scanner(url);
            urlScan.useDelimiter(",");
            count++;
            while(urlScan.hasNext()){
                String name = urlScan.next();
                String last = urlScan.next();
                int score = urlScan.nextInt();
                Student e = new Student(name,last, score);
                studentList.add(e);

            }   
        }
        System.out.println("The file has data for" +count+ "instances");
        int option;
        do{

        System.out.println("********");
        System.out.println("Options:");
        System.out.println("********\n1. List \n2. Add Student \n3.Delete Student \n4. Exit \n******** ");
        System.out.print("Select option: ");
        option = scan.nextInt();

        if(option == 1){    
        int index = 0;
        while(index<studentList.size()){
            System.out.println(studentList.get(index));
            index++;
        }
        }
        else if(option == 2){
            System.out.print("Enter the name of the student: ");
            String newName = scan.next();
            System.out.print("Enter the last name of the student: ");
            String newLastName = scan.next();
            System.out.print("Enter the exam score of the student: ");
            int newScore = scan.nextInt();
            Student b = new Student(newName, newLastName, newScore);
            studentList.add(b);}
        else if(option == 3){
            System.out.print("Enter the name of the student to remove: ");
            String remove = scan.next();
            System.out.print("Enter the last name of the student: ");
            String remove1 = scan.next();
            int location = studentList.indexOf(remove);
            location = studentList.indexOf(remove1);

            studentList.remove(location);
            }   

        }while(option!=4 && option <4);
    }//main
}//class

And this is the other class
public class Student implements Comparable<Student>{
    String firstName, lastName;
    int score;

public Student(String firstName, String lastName, int score){
    this.firstName = firstName;
    this.lastName = lastName;
    this.score = score;
}

public String getFirstName() {
    return firstName;
}

public void setFirstName(String firstName) {
    this.firstName = firstName;
}

public String getLastName() {
    return lastName;
}

public void setLastName(String lastName) {
    this.lastName = lastName;
}

public int getScore() {
    return score;
}

public void setScore(int score) {
    this.score = score;
}
public String toString(){
    return firstName + " " + lastName + ", exam score is "+ score;
}

@Override
public int compareTo(Student c) {

    return score-c.getScore();
}

}
As you can see, up to now I have created the class where my compare method is but I have difficulties on using it. Also I have had difficulties on deleting one of the Array List parts by just writing the name and last name of the student. If somebody would help me, I would be very thankful.

A: Basically what you want is an ordered collection. As @duffymo has stated, think about a creating a custom Comparator using your score.
There is plenty of info here

A: In terms of deleting students from the list.
The studentList is a list containing Student objects. 
This means that the follow code:
System.out.print("Enter the name of the student to remove: ");
String remove = scan.next();
System.out.print("Enter the last name of the student: ");
String remove1 = scan.next();
int location = studentList.indexOf(remove);

Tries to find the index of a Student given the first name. This will return -1 as you're searching for a String and not a Student object.
Instead you have to iterate through your studentList and compare the first and last name of each Student element with the values of remove and remove1.
for(Student student : studentList) {
    if(student.getFirstName.equals(remove) && student.getLastName.equals(remove1)) {
        // remove the student.
    }
}

Also you could consider giving each Student an ID as an unique identifier.

A: try this to sort studentList
  Collections.sort(studentList, new Comparator<Student>() 
    {
        @Override
        public int compare(Student  x, Student  y)
        {
            if(x.score >= y.score)
                return 1;
            else 
                return -1;

        }
    });


A: well you can change your compareTo method as
public int compareTo(Student another)
{
    if (this.score > another.score)
        return -1;
    if (this.score < another.score) 
        return 1;
    else
        return 0;
}

this should show it as decreasing order you can change the operator
than use whereever you want to sort it
Collections.sort(studentList)

Also if you don't want to use Collections.sort() method I can show you how you can write it with for loop under add option
Student newStd = new Student(name, last, score);


                for(int i=0;studentList.size()>i;i++)
                {
                    int size = studentList.size();
                    if(newStd.compareToCustom(studentList.get(i))>0)
                    {
                        studentList.add(i, newStd);
                        break;
                    }
                    else if(newStd.compareToCustom(studentList.get(size-1))<0)
                    {
                        studentList.add(studentList.size(), newStd);
                        break;
                    }
                    else if(newStd.compareToCustom(studentList.get(i))==0)
                    {
                        studentList.add(i++, newStd);
                        break;
                    }
                }

for the remove part you can use
else if ( option == 3)
            {
                System.out.print("Enter the first name of student will be deleted: ");
                String removeName = scan.next();
                System.out.print("Enter the last name of student will be deleted: ");
                String removeLastName = scan.next();

                for ( int i = 0; i < studentList.size(); i++)
                {
                    Student deleted = studentList.get(i);

                    if ( deleted.getFirstName().toLowerCase().equals(removeName.toLowerCase()) && deleted.getLastName().toLowerCase().equals(removeLastName.toLowerCase()))
                    {
                        studentList.remove(i);
                        System.out.println("The student has been deleted.");
                        break;
                    }
                    else
                    {
                        System.out.println("This student is not found");
                        break;
                    }

                }

            }

