0
我需要创建一个链表,并用容器中的“容器”和“元素”填充它。用其他列表中的单独元素和元素填充java列表的最佳方法是什么?
这是我的代码:
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;
}
是否有在java中的任何方法,使之更好(更简洁,干燥等)?
你能绕过列表填充它的对象? –
“更好?”是什么意思? –
@SotiriosDelimanolis它不是通信对象的责任......至少在我的对象模型中... – yashaka