java - List versus ArrayList -


which 1 better , why ?

a) list<string> list = new arraylist<>();

b) arraylist<string> list = new arraylist<>();

it depends on context.

if care list semantics , not particular implementation, go list<string>. if want enforce particular implementation, go arraylist<string>, linkedlist<string> or else.

in cases, want go on interface , not particular implementation.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -