Ho cambiato un pņ le cose, ho creato un'apposita classe che implementa Iterator:

codice:
import java.util.Iterator;

public class ElementsIterator implements Iterator
{
	private DList list;
	private LNode cursor;
	
	public ElementsIterator(DList list)
	{
		this.list=list;
		cursor=(list.size()==0)? null : list.getHeader().getNext();
	}
	
	public boolean hasNext(){return cursor!=null;}
	
	public Integer next() throws NoSuchElementException{
		if(cursor==null)
			throw new NoSuchElementException("Nessun successivo");
		LNode node=cursor;
		Integer ret=cursor.getElement();
		
		cursor=(cursor.getNext()==null) ?null : cursor.getNext();
		
		return ret;
	}
	
	public void remove() throws UnsupportedOperationException
	{
		throw new UnsupportedOperationException("Remove is not allowed");
		
	}
	
	public Iterator
}
E la classe iterabile con il metodo che itera č questa:

codice:
import java.util.Iterator;

public class ElementsIterator implements Iterator
{
	private DList list;
	private LNode cursor;
	
	public ElementsIterator(DList list)
	{
		this.list=list;
		cursor=(list.size()==0)? null : list.getHeader().getNext();
	}
	
	public boolean hasNext(){return cursor!=null;}
	
	public Integer next() throws NoSuchElementException{
		if(cursor==null)
			throw new NoSuchElementException("Nessun successivo");
		LNode node=cursor;
		Integer ret=cursor.getElement();
		
		cursor=(cursor.getNext()==null) ?null : cursor.getNext();
		
		return ret;
	}
	
	public void remove() throws UnsupportedOperationException
	{
		throw new UnsupportedOperationException("Remove is not allowed");
		
	}
	
	public Iterator
}
Il metodo iterator č sbagliato, ma mi chiedevo dą errore per esempio ache per via del tipo?
Io devo restituire praticamente un iteratore degli elementi che nella mia lista sono uguali al valore passato come parametro al metodo e ho pensato di inserire questi nodi in un'altra lista su cui iterare.
Forse č per questo?
Perchč dovrebbe restituire un iteratore di tipo Integer e io invece pretendo di restituire una lista?

Non saprei come fare, se non inserendo i valori in un' altra lista.