on 12-12-2006 10:38 AM
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
Hi,
Need not to struggle that much you can simple use <b>this.clear()</b>
Regards
Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You are extending ArrayList. It seems you want to create your special list.
Then if you are using
this.removeAll(tmpCol)
use super() to initialize the parent arraylist instead of
ArrayList tmpCol = new ArrayList();
Well i am still not able to understand your scenario. get you please elaborate a more on what you want to achieve.
Regards,
Ashwani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.