Consider this function which sums the results of a range of values passed to a function...
int totalColumnWidth = 0;
for(int columnIndex = 0; columnIndex < columnCount; columnIndex++)
totalColumnWidth += getWidthForColumn(columnIndex);
It just seems so verbose! In other languages, I can do that in one line, which has the added benefit of allowing me to make totalColumnWidth read-only. Is there any such thing in Java 7 (we're doing Android development for KitKat API 19).
My guess is 'no' since I understand Java 7 doesn't support lambdas which are needed for this type of functionality (you'd have to pass in the getWidthForColumn()
call), but I'd love to be mistaken.