更新时间:2022-12-23 11:52:25
LinkedList ob = new LinkedList() 不是 100% 正确吗?
Isn't LinkedList ob = new LinkedList() 100% correct?
好吧,我建议使用通用形式,但可以肯定 - 如果您想使用 特定 到 LinkedList
的功能,您需要相应地声明变量.
Well I'd suggest using the generic form, but sure - if you want to use functionality which is specific to LinkedList
, you need to declare the variable accordingly.
您可能想要检查 Deque
或 Queue
接口有你想要的.如果他们这样做,请使用那些与描述您需要什么而不是您将使用什么实现的想法保持一致的内容.
You might want to check whether the Deque<E>
or Queue<E>
interfaces have what you want though. If they do, use those in-keeping with the idea of describing what you need rather than what implementation you'll use.