📌  相关文章
📜  用于显示数组中可被 3 整除的数字的代码 - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:41.059000             🧑  作者: Mango

代码示例1
public static void main(String[] args) {
    multiple_3(new int[] { 3, 9, 45, 88, 23, 27, 68 });
}

public static void multiple_3(int[] ints) {
    int count = 0;
    for (int n : ints) {
        if (n % 3 == 0) {
            count++;
        }
    }
    System.out.println("This is the amount of numbers divisible by 3: " + count);
}