批次检验
您负责对不同批次的巧克力礼盒进行质量检验。您知道其中有一批过重,但不确定是哪一批。请按顺序打印每一批的重量,找出超过 220g 的那一批。
本练习是课程的一部分
Java 中级
练习说明
- 使用正确的符号来标记元素与集合之间的关系。
- 调用合适的变量,打印每个批次的重量。
交互式实操练习
通过完成这段示例代码来试试这个练习。
class WeightWatcher {
public static void main(String[] args) {
int[] weights = {198, 190, 188, 187, 190, 198, 201, 250, 203, 210, 205, 170, 180, 200, 203, 210, 180};
// Use the correct symbol to mark the difference between the elements and the collection
for (int weight ____ weights){
// Call the right variable to print how much each batch weighs
System.out.println(____);
}
}
}