arrays - Java classes and ArrayList clarification -
i have created java class , trying larn how arraylist
work.
let's have top class called complex
. in class have houses
, employees
etc, of these separate classes.
if wanted create arraylist
how go that?
the number of elements dynamic when says add together new house, phone call method asks questions relating house , adds list i'm assuming?
to create arraylist
hold objects of type house
, can do:
arraylist<house> houselist = new arraylist<house>(); houselist.add(new house());
to loop on items in list
for(house house:houselist){ // house object }
see the documentation larn other functions.
java arrays list class arraylist
No comments:
Post a Comment