Buongiorno.
Per evitare problemi ho dichiarato la inner class non statica, ma purtroppo periste un problema:
nella next è presumibile che io debba resituire un tipo T, ma non riesco, perché la get(int) dei Vector resituisce un Object. Come posso render eil mio Object resituito un tipo T?
codice:public Iterator <T> elements(){ return new SetGene(this);} private class SetGene implements Iterator { private Set2 s; private int n; private T t1; public T next() {t1= s.els.get(n); n++; return t1;} //con ritorno dalla get richiede T public SetGene(Set2 s){this.s=s; n=0;} public boolean hasNext() {return (n< s.els.size());}
Purtroppo non posso utilizzare l'ietaratore preessistente in Java.

Rispondi quotando