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 ?
LVL 2
bachra04Asked:
Who is Participating?
 
for_yanConnect With a Mentor Commented:
so I don't know if you use Vector as association - so you create wrapper
around vector - then the method above with v representing Vector is fine
If you extend Vector then
you just use

Object ob = this.elementAt(0);
this.remove(0);

instead of v
0
 
for_yanCommented:
I guess you can say remove(0) fro a Vector
0
 
bachra04Author Commented:
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.
0
 
for_yanCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.