There isn’t a class that extends List for which you can set a limit on its size and that it behaves like a Queue object if you add an item beyond its fixed size.
In the previous post about the Comparable interface I explained how you can extend a class of objects that implement the Comparable interface and then order them in a list according to the logic defined in the overridden method compareTo. If you want to be able to sort the list according to a number of…
A List contains objects that you can order according to a natural order using the static method Collections.sort(List list) if the objects implement the Comparable interface.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.