What best way to populate java list with separate elements and elements from other lists? -
i need create linked list , populate "containers" , "elements" containers.
this code:
public list<webelement> getexpectedelements(){ list<webelement> list = new linkedlist<webelement>(arrays.aslist( inetconnection, wiredconnection, phonesconnection, usbconnection, wificonnection )); list.addall(inetconnection.getexpectedelements()); list.addall(wiredconnection.getexpectedelements()); list.addall(phonesconnection.getexpectedelements()); list.addall(usbconnection.getexpectedelements()); list.addall(wificonnection.getexpectedelements()); return list; }
is there way in java make nicer (more laconic, dry, etc.) ?
you @ least introduce loop:
list<webelement> containers = arrays.aslist(inetconnection, wiredconnection, phonesconnection, usbconnection, wificonnection); list<webelement> list = new linkedlist<webelement>(containers); (webelement e : containers) list.addall(e.getexpectedelements());
Comments
Post a Comment