I have a class Arraylist.java...i want to make my class to behave as Set...then what need to do? What changes i have to do in my class.....
kindly reply..
Did they really ask you that question in an interview? Lists and Sets are like bicycles and boats. The interviewer is asking you to ride your bicycle across the lake. Or maybe to sail the boat up the street.
i believe that the interviewer wants to add the condition of uniqueness... So the answer would be
" I will modify (or override if you are making a subclass) the add method of the data structure to add a contains check before adding. If the object is present.. return false and not add... else add