2

I'm not sure what the difference between the following declarations are :

ArrayDeque ad = new ArrayDeque();
Deque d = new ArrayDeque();

Is one of them more proper than the other? Or are there situations where you would in fact use one over the other. I realize that ArrayDeque implements Deque but I'm not sure how that plays into the above declarations.

Thanks

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
Coder Lam
  • 395
  • 1
  • 3
  • 13
  • This is a lot more specific than the other question. That's about interfaces, this is about two libraries. – Anubian Noob Jan 23 '15 at 04:23
  • @AnubianNoob Which libraries? How is `Deque` vs `ArrayDeque` different from `List` vs `ArrayList`? I don't see any difference between this question and the duplicate. – Sotirios Delimanolis Jan 23 '15 at 04:26
  • @AnubianNoob `ArrayDeque` is an implementation of the `Deque` interface. They are _not_ two different libraries. This is exactly like `ArrayList` and `List`. – Dawood ibn Kareem Jan 23 '15 at 04:47
  • Fair enough, I was just thinking this question is a lot narrower in scope than the other one. I guess they're close enough that the other one solves this. – Anubian Noob Jan 23 '15 at 04:49
  • just to follow up then, is there any scenario where it might be acceptable (or where you should) use ArrayList myList = new ArrayList(); instead of List myList = new ArrayList(); is it just the intuition that since ArrayList is by definition a List, it's best/proper to declare all ArrayList as Lists? – Coder Lam Mar 12 '15 at 18:11

0 Answers0