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

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -