Java List vs ArrayList

前端 未结 7 1734
有刺的猬
有刺的猬 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 01:45

    List is an interface, somewhat like a class with some = 0 methods in C++. You can't instantiate it.

    But ArrayList "inherits" List (or in Java terms, implements it), so those references are assignment-compatible.

提交回复
热议问题