Hallo,
ich will mit einem Iterator durch ein Collection durchlaufen, ansich ja ne Standardfunktion. Doch mein Iterator
wirft ne ClassCast Exception, obwohl alles vom Typ String ist.
Hier mal der Code:
Weiss einer woran das liegen kann?
Vielen Dank schon mal.
Gruss
May
ich will mit einem Iterator durch ein Collection durchlaufen, ansich ja ne Standardfunktion. Doch mein Iterator
wirft ne ClassCast Exception, obwohl alles vom Typ String ist.
Hier mal der Code:
Code:
public class HandleAPI {
Class app;
Hashtable table;
Collection<String> names;
public HandleAPI(Hashtable _table, int _amount) {
table = _table;
amount = _amount;
}
public void create() {
names = table.values();
for ( Iterator<String> i = names.iterator(); i.hasNext(); )
{
String s = i.next(); // Bei diesem String wirft er die Exception, obwohl die Collection und der
Iterator beide vom Typ String sind!!
app = createObject(s);
}
Weiss einer woran das liegen kann?
Vielen Dank schon mal.
Gruss
May