java 在Java中可被7整除

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java 在Java中可被7整除相关的知识,希望对你有一定的参考价值。

/******************************************************************************
 *
 *  Reads in two integer command-line arguments x and y and prints "true"
 *  if both are divisible by 7, and false otherwise.
 *
 *  a % 7 is the remainder when you divide 7 into a. If the remainder
 *  is 0, then a is divisible by 7.
 *
 ******************************************************************************/

public class Divisibility {
    public static void main(String[] args) {
        int x = Integer.parseInt(args[0]);
        int y = Integer.parseInt(args[1]);
 
        boolean isDivisible = (x % 7 == 0) && (y % 7 == 0);

        System.out.println(isDivisible);
    }

以上是关于java 在Java中可被7整除的主要内容,如果未能解决你的问题,请参考以下文章