In the following method, I encounter "java.lang.IndexOutOfBoundsException: Index: 0, Size: 0" error at result.set. There is no compilation error, but after running I get this error. What is wrong with this arraylist assignment? I want to set first and second list variables.
static List<Integer> compare(List<Integer> a, List<Integer> b) {
    int ca=0;
    int cb=0;
    List<Integer> result = new ArrayList<Integer>();
    for(int i=0; i<a.size(); i++){
        if(a.get(i) > b.get(i)){
            ca++;
        }
        else if(a.get(i) < b.get(i)){
            cb++;
        }
    }
    result.set(0, ca);
    result.set(1, cb);
    return result;
}
 
    