java - Combining a static array with a dynamic ArrayList -


i want combine static array (such int[]) dynamic array such arraylist<string>

for example, know count of houses: 10 (fixed), don't know count of humans live in house. count change dynamically, list.

is there option create datatype can fulfill both criteria?

an arraylist dynamicly sized data structure backed array. sounds me have array of house each house has list<human> field.

house[] homes = new house[10]; 

and class like

class house {     private list<human> people = new arraylist<>();      public list<human> getpeople() {         return people;     } } 

then total count of people in homes might use like

int count = 0; (house h : homes) {     count += h.getpeople().size(); } 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -