Wiki Markup |
---|
According to the Java API \[[API 2006|AA. Bibliography#API 06]\], interface {{Enumeration}} documentation: |
An object that implements the
Enumeration
interface generates a series of elements, one at a time. Successive calls to thenextElement
method return successive elements of the series.
...
Upon encountering the first "Harry", it successfully removes the entry and the size of the vector diminishes to three. However, the index of the Enumeration does not decrease by one, causing the program to use "Tom" for the next (now final) comparison. As a result, the second "Harry" continues to remain in the vector unscathed, having shifted to the second position in the vector.
...
Wiki Markup |
---|
According to the Java API \[[API 2006|AA. Bibliography#API 06]\], interface {{Iterator}} documentation: |
Iterator
takes the place ofEnumeration
in the Java collections framework. Iterators differ from enumerations in two ways:
- Iterators allow the caller to remove elements from the underlying collection during the iteration with well-defined semantics.
- Method names have been improved.
...
Using Enumerations
when performing remove operations on a vector may cause unexpected program behavior.
Rule Guideline | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
MSC12-J | low | unlikely | medium | P2 | L3 |
...