Skip to Content
0
Former Member
Dec 12, 2006 at 10:38 AM

ArrayList - delete all objects

37 Views

Hi,

just wanted to know how i delete all elements from a class of type "ArrayList".

my code won't work in any way:(.

the ArrayList contains objects of type "login" referenced as loginliste

(left out the not relevant code-parts)

public class LoginBean extends ArrayList {

	Login loginListe;

	public void eraseData() {
	//Deltes all objects within sessionbean
		
		ArrayList tmpCol = new ArrayList();
		
		ListIterator li = this.listIterator();
        while (li.hasNext()) {
        	
        	this.loginListe = (Login)li.next();
        	
        	tmpCol.add(loginListe);
            	
            }
        
        //remove all found elements
        this.removeAll(tmpCol);
        
        }
}

Hope anyone might help

thx

lars