java - Raw Arrays vs Collection List -


i have gone through many codebases on github , everywhere found 1 common pattern use arrays instead of lists.

example :

class attributes {    ...    ...    attribute[] attribute;    ...    ... } 

so question here is, why of these projects using raw arrays , not collections? below code still same functionality wise , using arrays require of code re-written handle expansion of array.

class attributes {    ...    ...    list<attribute> attribute;    ...    ... } 

i don't know sources, i'm pretty sure collections used more arrays, since provide dynamic structure. yet there reasons use arrays well;

-if have limited memory, using arrays better choice.

-if have strict deadlines on program, using arrays better choice.

-if know amount of elements use in program, using arrays better choice.

in nutshell, if need performance, or have limited resources use arrays. if need functionality, use collections.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -