|
-
September 18th, 2000, 11:41 AM
#1
Insert?
Any way to insert an array element and automatically push the rest of the elements down in the array? IE. similar to insertElementAt for JList?
-
September 18th, 2000, 02:24 PM
#2
Re: Insert?
Hi
If you are talking about a normal array you would have to take the elements out of the array and then add them all again you the right order. So I think it would be best if you use a Stack instead. Stack has last in is the first out.
Stack s = new Stack();
s.push(Object);// adds an Object
s.pop();// takes the first Object out, which is the last object entered
If you are adding numerical values, you will have
to cast them to the appropriate wrapper class(and
cast them back again when you take them out), as
Stacks only take Objects.
Phill.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|