CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Insert?

  1. #1
    Join Date
    Mar 2000
    Posts
    123

    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?


  2. #2
    Join Date
    Sep 2000
    Location
    Melbourne --> Australia
    Posts
    68

    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
  •  





Click Here to Expand Forum to Full Width

Featured