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
Post a Comment