Returns a value immediately from a collection over java 8 streams
Consider a list int [] (in an array).
Now I want to check that the last element of the integer array is 10. If any of the elements in the array is 10 then I want to return true immediately. Else I want to return false.
This is my method to achieve this.
boolean checkList(List<int[]> attrList, Parent parent) {
for (int[] list : attrList)
{
if(parent.isAttributeEqualsTo10(list[list.length-1]))
return false;
}
return true;
}
Now how can I achieve this using Java 8 streams since we are iterating over a collection.
+3
source to share