I have a list in Java, but there is a condition: if the list size exceeds 10, then i have the remove the excess contents the starting without iterating,
Eg: if the list contains {1,2,3,4,5,6,7,8,9,10,11,12,13,14}
then the result should be
{5,6,7,8,9,10,11,12,13,14}
Also, please note that the Java version am using is Java 6.
I have tried with subList
, but even this operation internally does the iteration which is causing performance issue.
public List<E> subList(int fromIndex,
int toIndex)