Solved

RemoveFirst J2ME

Posted on 2012-03-09
4
394 Views
Last Modified: 2013-11-24
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
Comment
Question by:bachra04
  • 3
4 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 37703138
I guess you can say remove(0) fro a Vector
0
 
LVL 2

Author Comment

by:bachra04
ID: 37703153
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
 
LVL 47

Expert Comment

by:for_yan
ID: 37703169
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
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 37703193
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to install java on RHEL image on EC2 4 51
Chrome and Firefox Java 5 66
java example issue 5 42
web project error add remove 1 49
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question