how to remove 1st value from a vector
Hi Folks!
Basically I am trying to remove 1st value in my Vector. also i need to store it in any
int variable. Can anydody tell me how can i do this please?
my vector is numberPackets
System.out.println("Vector packets..."+numberPackets);
Thanks alot in advance
[325 byte] By [
asyed01a] at [2007-11-27 8:47:05]

> Hi Folks!
>
> Basically I am trying to remove 1st value in my
> Vector. also i need to store it in any
> int variable. Can anydody tell me how can i do this
> please?
>
>
> my vector is numberPackets
>
> > System.out.println("Vector
> packets..."+numberPackets);
> /code]
>
> Thanks alot in advance
if you know the first element you can remove it like this:
[code]
if (numberPackets.contains("text")){
numberPackets.get(0); // do something with the first element
numberPackets.remove(0);
}
How do you store it in the vector, since Vector's cannot store primitives.
Vector v = new Vector();
int i = 1;
v.add(i); // will fail for jdk <= 1.4.2 // will auto box into Integer in 1.5 >
v.add(Integer.valueOf(i));//works in both
int b = ((Integer)v.remove(0)).intValue();//store the int value of the Integer at index 0 into b and removes it from the vector.