Link to home
Start Free TrialLog in
Avatar of bachra04
bachra04Flag for Canada

asked on

RemoveFirst J2ME

I have the following code in Java :

MyPacket = MsgQueue.removeFirst();

MsgQueue is a list I want to mimic the same behaviour in J2ME using a Vector:

Is there a way to do that ?
Avatar of for_yan
for_yan
Flag of United States of America image

I guess you can say remove(0) fro a Vector
Avatar of bachra04

ASKER

Not exactly :

 * This method removes first element of List and shifts the subsequent
     * elements to the left. It returns the element previously at the first index
     * of the  List.
public Object removeFirst() {
Object ob = v.elementAt(0);
v.remove(0);
return ob;

}


remove(0) will also change indexes odf all subsequent emelements:

http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Vector.html#remove%28int%29
ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial