How do I make an ArrayList not exceed a size of 3, as shown here:
ArrayList <Integer> list = new ArrayList<Integer>(3);
Is there a certain method that will ensure the ArrayList does not grow past 3 entries?
I tried ensureCapacity()
, trimToSize()
, but they do not do what I want