I have a list of ints
like the following one:
1318 1065 0
1392 1109 0
1522 1114 2
1764 1134 0
1643 1172 0
1611 1141 0
1608 1142 4
1689 1180 0
1546 1144 0
1811 1121 1
1682 1144 0
1687 1203 0
1751 1138 0
1702 1227 0
My goal is to keep only entries where the third element is a 0.
I've tried a few things like:
for( int i=0; i<data_fin.size();i++) {
data_fin.removeIf(s -> !((data_fin.get(i)[2]) == 0));
}
I get the error 'Local variable i defined in an enclosing scope must be final or effectively final'.
Can anyone help me understand what I'm doing wrong? I'm quite new to Java and I'm probably using removeif
wrong, so I would appreciate the help!
My goal is to
keep
only entries where the third element is a 0
You don't need a loop in this, all you need is :
data_fin.removeIf(a -> a[2] != 0);