Menu

#3 Parameterize Iterator

open
nobody
None
5
2014-09-05
2010-03-30
Friedrich
No

I copied an example form your site, that contains the following code:
...
if (!config.success()) {

System.err.println();

// print out specific error messages describing the problems
// with the command line, THEN print usage, THEN print full
// help. This is called "beating the user with a clue stick."
for (java.util.Iterator errs = config.getErrorMessageIterator();
errs.hasNext();) {
System.err.println("Error: " + errs.next());
}
...
}
...

Eclipse immediately displayed a warning that I use Iterator without specifying the type. I looked up in the source code:

public Iterator getErrorMessageIterator() {
return (chronologicalErrorMessages.iterator());
}
and found that in fact the Iterator iterates over a List called chronologicalErrorMessages.

So in order to avoid warning it would be cool to change the generic Iterator to Iterator<List> and update the examples accordingly. I do not know if this situation occurs also in other parts of your code.

Note that this does NOT lead to an error - it gives just a warning (in eclipse).

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.