Highbridge Capital Interview Question
Java DevelopersTeam: Risk Metrics
Country: United States
Interview Type: Phone Interview
Making object mutable/nonmutable should not depend on what interface you implement or what class you extend.
There are basic differences on ArrayList and Vector or some other collections in java in regard to sycronization, allowing null values, keeping their order and the like - not with modifiebility as far as I know.
For immutability, you can consider using final keyword not change its values
I wouldn't do either. I would create an immutable wrapper for my list by calling Collections.unmodifiableList (List<T> ls). But that is internally implemented as implementing the List interface and does not extend ArrayList. This only makes sense, since not every list wrapped in this wrapper is necessarily an ArrayList. It could be a LinkedList, etc.
- eugene.yarovoi July 26, 2012