Solved

RemoveFirst J2ME

Posted on 2012-03-09
4
392 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android studio getdrawable(int) is deprecated 4 82
JDeveloper 12c for 32 bit 4 84
Desingning Refactoring existing code 2 24
String array comparison 4 32
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

813 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now