Any user who would like to access the java.util.ArrayList
facility, has to obey the usage contract provided in java.util.List
.
But one can break this usage contract easily and access the methods trimToSize
public void trimToSize() { ... }
and ensureCapacity
public void ensureCapacity(int minCapacity) { ...}
Because these two methods are neither overridden from java.util.AbstractList
nor implemented from java.util.List
.
So, Why these two methods provide public
level access and break the abstraction provided by java.util.List
?