什么是不同之处?(多态性)

huangapple go评论57阅读模式
英文:

what is the difference between? (polymorphism)

问题

下面是翻译好的部分:

List<String> lst = new LinkedList<>();


LinkedList lst = new LinkedList<>();

英文:

What is the difference between

List&lt;String&gt; lst = new LinkedList&lt;&gt;();    

and

LinkedList&lt;String&gt; lst = new LinkedList&lt;&gt;();

答案1

得分: 1

除了便利性外,两者没有区别 - 在第一种情况下,如果您发现在您的应用程序中使用其他List实现(例如ArrayList)效果更好,您可以将LinkedList更改为其他实现,而无需更改任何其他代码。

英文:

There's no difference other than convenience - in the first case you can change LinkedList to other List implementation (such as ArrayList), if you find that it works better in your application, for example, without the need to change any other code.

huangapple
  • 本文由 发表于 2020年7月22日 05:26:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/63023354.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定