I want to create a Stack in Java, but fix the size. For example, create a new Stack, set the size to 10, then as I push items to the stack it fills up and when it fills up t
A LinkedBlockingDeque is one simple option. Use the LinkedBlockingQueue(int) constructor where the parameter is the your stack limit.
As you observed, Stack and Vector model unbounded sequences. The setSize() method truncates the stack / vector. It doesn't stop the data structure from growing beyond that size.