Different collection classes have different implementation about how to access the individual objects in the collection. For ex. the Arraylist
class stores the individual objects as an array of Object, whereas the LinkedList
class uses an inner class Entry
to store the individual objects. However, these members are encapsulated and marked as private so that they are not visible to the programmer. The main reason behind this is to provide the programmer with a simple set of methods to perform various operations without caring about how the method is implemented.
My concern is that, if this is possible then a LinkedList can be split into two lists like a charm, saving a lot of CPU overhead. What I do now is that I copy one part of the List (new Sublist()...) and then I clear the corresponding entries in the original List.
Normally, you won't get hold of the members which manage your collection and perform operations like splitting. But, if you still want to access these members to improve the performance, you can always create your own classes, which allow you to get hold of the 'next'. You can always tweak the existing code in the predefined classes like LinkedList
and create your own class, say MyLinkedList
. Or you can extend these classes and write your own methods.