I'm working on a programm where a two lists are created and they have to be compared to find if there are two RECURS that are the same. I'm testing if it works (and have to use these methods) but I keep having the same problem; cannot find symbol.
public class Duplicate {
public Duplicate(){};
static ArrayList<Recurs> findDuplicate(ArrayList<Recurs> l1, ArrayList<Recurs> l2){
ArrayList<Recurs> l3 = new ArrayList<>();
for(int i=0; i<l1.size(); i++){
for(int j=0; j<l2.size();j++){
if(l2.get(i).equals(l1.get(j))){
l3.add(l1.get(i));
}
}
}
return l3;
}
}
This code is supposed to work. By the way, I've programmed a class called Recurs, which supposedly also works (I made another test and that worked ok where I created an equals method).
The problem comes now.
public class Test {
public static void main (String[] args){
Recurs o = new Recurs(3, "a");
Recurs e = new Recurs(2, "b");
Recurs m = new Recurs(4, "a");
Recurs n = new Recurs(2, "b");
ArrayList<Recurs> l1= new ArrayList<>();
l1.add(o);
l1.add(e);
ArrayList<Recurs> l2= new ArrayList<>();
l2.add(m);
l2.add(n);
ArrayList<Recurs> l3 = new ArrayList<>(findDuplicate(l1, l2))
}
}
I create a test where it is supposed to show me that this part is working, but i've got a problem at the last line of code, because it tells me it cannot find findDuplicate.
I'm new at using Java, if someone finds the problem, could they also point out the reason why it is happening?