LinkedList index addition problems
I'm currently adding double type values to a LinkedList, and then using the index to go through these values. The problem is when I try to add a new value at the current index position.
Why does the add(int index, Object Element) method for a LinkedList replace the existing value with the new one and move the existing value forward one place in the index?
Is there any way to place the new value one place after the current index position, instead of before it with the above method?
Is there another way of adding new values to an existing LinkedList?
You just described what add(index.Object) does in a LinkedList. That's "how it works". If you really wanted to change that, you could extend the LinkedList class with one of your own, and intercept the add(index,Object) method, so it mvoes forwad the the next index and adds it there.
Thanks for the help.
I am so pleased to be able to say that I've actually got it working correctly now. I was being a complete ninny about the whole thing. I had added extra lines setting an incorrect current list index value. As soon as I removed those lines everything worked as required.
Thanks to all for their help.