我需要创建一个链表并用容器中的“容器”和“元素”填充它。
这是我的代码:
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有什么办法让它更好(更简洁,DRY等)?