java - What values do you return from an ArrayList if the method returns an Enumeration? -


so upgrading old code uses vector arraylist , unsure use replace old vector segment.

public enumeration enumeratemapping() {     return mappinglist.elements(); } 

i need replace .elements() arraylist equivalent. if happens know of link translation these helpful well.

arraylist (and collections) implement iterable, should return iterator() :

public iterator enumeratemapping() {     return mappinglist.iterator(); } 

it better use generic type instead of raw type, i.e. iterator<elementtype>.

as enumeration javadoc suggests, recommended use iterator instead of enumeration :

note: functionality of interface duplicated iterator interface. in addition, iterator adds optional remove operation, , has shorter method names. new implementations should consider using iterator in preference enumeration.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -