Java list best practices

I need some containers to hold elements. If I'm going to try to get the size () I element, I'll get the element number I. or use an iterator, which starts at the beginning of the container after trying to get the last element? What are the best practices in both cases? I mean performance and ease of use

Solution

For the first part, it may just require n% list size()?

For the iterator part, create a class that wraps the iterator. When next () returns null, just reset the iterator

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>