【发布时间】:2020-04-01 17:36:57
【问题描述】:
我应该在某些条件下返回myList 中的元素计数。
每个要计数的Integer 元素的条件是:
不少于40
public int count(ArrayList<Integer> aMyList) {
int count = 0;
for (int aInteger : aMyList) {
if (aInteger <= 40)
count++;
}
return count;
}
有什么问题吗?提前致谢。
【问题讨论】:
-
“有什么问题吗?”为什么不测试一下?
-
将您的条件更改为
aInteger >= 40 -
@SunilDabburi 如何整数> 40?
-
我更新了我的评论。看到这个问题。
not less than 40 -
问题一点都不清楚。请改写问题
标签: java arraylist conditional-statements counting