Java List vs ArrayList

前端 未结 7 1763
有刺的猬
有刺的猬 2020-12-07 01:14

As a C++ oldtimer I have managed to solve my problem but I can not wrap my head around the underlying Java mechanisms here:

Vector x = new Vec         


        
      
      
      
7条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 02:03

    Yes. Because List is an Interface and in Java you cannot instantiate an Interface. You can only instantiate a class.

    ArrayList is a class that's implementing List<> that's why you can instantiate it. :)

提交回复
热议问题