0
我想簡單地從ArrayList中選擇元素,就像我可以在R中做的那樣。例如,在RI中可以選擇索引列包含的值大於1500的行,導致一個新的數據幀:R數據幀類型的行選擇,但對於Java 8 ArrayList
ndf = df[df$index>1500,]
在Java 8中,我想做一個ArrayList的等價物。我能想出的最簡潔的方式是:
List<IndexCount> signficantRowIndexList = new ArrayList<>();
<the list gets loaded with some objects>
List<IndexCount> selectedList = new ArrayList<>();
signficantRowIndexList.stream()
.filter((ic)->ic.index > 1500)
.forEach((ic)->selectedList.add(ic));
這是最簡潔的方法嗎?