I have a custom class
class StackInfo {
int start, size, capacity;
}
and to verify the total number of elements present in an array of such info I have
private int numberOfElements(StackInfo[] info) {
int size = 0;
for (StackInfo si : info) {
size += si.size;
}
return size;
}
I tried converting it using streams to the following:
private int numberOfElements(StackInfo[] info) {
return (int) Arrays.stream(info).map(s -> s.size).count();
// ^^
// to convert long
}
But the output for the above code is not correct either after casting as well.