I have this class:
public class Phone{
private String number;
//get and set of class
}
Then i have another class that uses the "Phone"
public class Antena{
private String name;
private ArrayList<Phone> phones;
}
Now before add an element i would like only add if the element don't exist in the array. I'm new in Java and after some research i have found that i need to override the equals method. So can anyone give me some hints please?
This is how i use the equals method:
if(!phones.equals(phone))
phones.add(phone);