为一个Atribut java设置多个值以筛选附加列表
我使用的是java8,我想为添加到列表中设置很多值,我编写了这些代码,并且工作正常,但我认为它们更好
private String value;
public List<Entity> finalList;
public List<Entity> getList() {
value= "AB";
List<Entity> list2;
List<Entity> list3;
finalList= EntityService.filtermethod(value);
list2= EntityService.filtermethod("BC");
for (Entity val : list2) {
finalList.add(val);
}
list3= EntityService.filtermethod("CD");
for (Reservation val : list3) {
finalList.add(reser);
}
return finalList;
}
谢谢大家
# 1 楼答案
对!!有数以千计的方法使代码更好,但请考虑学习基本的东西,
我缩小了你的方法
getList()