Article View: borland.public.jbuilder.java.language
Article #20083Re: How work removeElementAt in java.util.Vector ?
From: Marc Jourdenais
Date: Thu, 30 Oct 1997 00:00
Date: Thu, 30 Oct 1997 00:00
33 lines
1276 bytes
1276 bytes
The Vector indexes its elements from 0 to size-1, not 1 to size.
- Marc
Mok Chenda wrote:
> I have the following code :
>
> Vector mCritereUtilisateur = new Vector();
>
> When i click on Button1 : i add string in my Vector
> ...............
> String vTemp;
> vTemp = a value;
> mCritereUtilisateur.addElement((String)vTemp);
>
> But when i want to delete a element, it's doesn't seem to work :
>
> Button 2 : removing the last element of my vector
> .............................
> int index = mCritereUtilisateur.size();
> System.out.println("Numero de index = " + index);
> if (index > 0) {
> mCritereUtilisateur.removeElementAt(index);
> }
>
> I have an error like :
> Exception occurred during event dispatching:
> java.lang.ArrayIndexOutOfBoundsException: 1 >= 1
>
> Thanks for you're response
> Mok Chenda
Technical Details
Message-ID:
<3458DE72.6A011FE6@pcn.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<01bce561$f73dc460$1d4602c2@titan>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,5ebec6c16aaca00c X-Google-Attributes: gidf74b3,public From: Marc Jourdenais <mjourden@pcn.com> Subject: Re: How work removeElementAt in java.util.Vector ? Date: 1997/10/30 Message-ID: <3458DE72.6A011FE6@pcn.com> X-Deja-AN: 286033443 References: <01bce561$f73dc460$1d4602c2@titan> Organization: None Newsgroups: borland.public.jbuilder.java.language