It depends a lot on your implementation.
If your objects are added to the end of the list in the order they were created, the first item in the list (index 0) will be the oldest.
If the objects in your list are added in an unknown order, and your objects have a method for querying the creation date, you can either:
- implement a sorted list based on the date the object was created
- iterate over each item in your list and find the oldest object
Option 1 carries overhead when items are added to the list or when you explicitly sort the list. Option 2 has overhead if you want to get the oldest object.
Andy
source share