I have to add only unique elements to an ArrayList. How can I override the equals method for that purpose? I want something like:
public boolean equals (Object in) {
    if(in == null) {
        return false;
    }
    else if(in instanceof UniqueFruits) {
        // ?? check whether the newly added element exists or not           
        return true;
    }
    else {
        return false;
    }       
} 
How to check whether the newly added element exists or not? I have to check on the Fruit Names.
 
     
     
     
    