I have an ArrayList(String) which contains a list of formatted dates like this:
element 1: "2012-5-1"
element 2: "2012-8-10"
element 3: "2012-12-5"
element 4: "2013-12-21"
element 5: "2013-12-13"
element 6: "2014-5-8"
What is the most efficient/framework way to create another list or normal primitive array that contains the unique year entries? For example my new list would contain:
element 1: "2012"
element 2: "2013"
element 3: "2014"
Try this
Where elements is the name of your list of date in the extended form.
Using as destination list
instead of an ArrayList could sightly improve the conversion efficiency (because the add is O(1) in LinkedList) but access a specific position in a second time, has a lower efficiency (O(n) vs O(1)).