bachra04
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 ?
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 ?
I guess you can say remove(0) fro a Vector
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.
* 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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.