• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 402
  • Last Modified:

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 ?
0
bachra04
Asked:
bachra04
  • 3
1 Solution
 
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
 
for_yanCommented:
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now