0

If I have an ArrayList, I can swap two objects using Collections.swap(list, indexA, indexB).

Is there anything similar for an ArrayDeque?

1 Answer 1

3

No ArrayDequeue is a Dequeue implementation, which means it is meant to be used to insert and remove elements only at start and end of the collection. It does not provide indexed access to elements (unlike List).

If you need indexed access to elements, and swap operation, you should reconsider your design and use another Collection type.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.