0

I've encountered a strange issue using a Deque.

I've reformatted my code twice now, and both forms has resulted in the same issue.

Whether i push() a String[] or an ArrayList<String> to the Deque (formatted appropriately for one or the other), it pop() 's as an Object. I cannot seem to use what so ever.

When i push() a String[] and then pop(), i cannot access indices. When i push() an ArrayList<String> and then pop(), i cannot use get() on it.

When i push() an element, it then pop() 's as something else. It says

"___ required, but Object found".

I don't understand why, or how i can use Deque successfully.

1 Answer 1

2

You need to explicitly cast your the variable returned by pop() to its original type e.g. String[] or ArrayList.

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

1 Comment

I thought i tried this, but i must have made some silly mistake. This is embarrassing- but thank you!

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.