gpt4 book ai didi

java - Main.isLeapYear 的结果被忽略 - 为什么?

转载 作者:行者123 更新时间:2023-12-02 11:07:33 25 4
gpt4 key购买 nike

public class Main
{
public static void main(String[] args)
{
isLeapYear(1600);
}

public static boolean isLeapYear(int year)
{
if (year < 1 || year > 9999) return false;

if (year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
return true;
}
else return false;
}
}

为什么会发生这种情况?当我运行代码时没有显示任何输出。

最佳答案

没有显示输出,因为您没有显示任何内容,要显示输出,请尝试以下操作:

public static void main(String[] args)
{
System.out.println(isLeapYear(1600));
}

关于java - Main.isLeapYear 的结果被忽略 - 为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50852608/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com