Re: removing error
- From: Mark Thomas <anon>
- Date: Tue, 10 Jan 2006 16:48:34 +0000
Thomas Weidenfeller wrote:
ste1986 wrote:
I have the following method to remove a String from an ArrayList. when I
try to run it I get a ClassCastException error. I have looked at lots of
examples of similar methods and I cant understand why this happens because
it looks right to me.
public void removePerson(String name) { Iterator it = person.iterator(); while (it.hasNext()) { Volunteer volunteer = (Volunteer) it.next(); if (volunteer.withPerson = true) { System.out.println ("Sorry that person is currently with a volunteer"); return; } else person.remove (name); } }
It is impossible to say what you are doing wrong. Would you please stop posting random snippets, but short(!), complete(!), real code(!)? Where does "person" come from in that code? Also, AT WHICH LINE DOES THE EXCEPTION HAPPEN? We don't operate a psychic hotline here. Provide the complete error message as given by the compiler. Don't type it in, copy-and-paste it. Relate it to the source code.
Also, people expect that you do some work on your own. We are not your remote debuggers. If you look at the error message you will see that it contains a line number and file name and lists the type which couldn't be casted. You did look at the error message, didn't you? Look at the mentioned source code line. It is in your source code (the code we probably don't have).
/Thomas
Thank you Thomas - I couldn't have put it better.
Mark .
- References:
- removing error
- From: ste1986
- Re: removing error
- From: Thomas Weidenfeller
- removing error
- Prev by Date: Re: removing error
- Next by Date: Re: Tomcat is a web server or an application Server
- Previous by thread: Re: removing error
- Next by thread: Re: removing error
- Index(es):
Relevant Pages
|