gpt4 book ai didi

java - 尝试从当前日期计算出生日期时,二元运算符 && 的操作数类型错误

转载 作者:行者123 更新时间:2023-12-01 19:27:34 26 4
gpt4 key购买 nike

我试图让用户输入 YR MON DAY,然后系统根据提供的输入计算当前年龄并在屏幕上显示年龄。

这是我的代码的开头:

static void checkAgeFormat(int current_date, int current_month,
int current_year, int birth_date,
int birth_month, int birth_year) {
int f = 0;
if(current_date <= 01 && current_date => 31) {
System.out.println("Invalid current_date");
f = 1;
}

我收到“二元运算符 && 的错误操作数类型”,我不明白为什么,而且我对编码还很陌生。感谢您的帮助

最佳答案

>=不是=>所以if(current_date<=1 && current_date>=31)

(不要使用 0 作为数字前缀,它会导致它们被解释为八进制)

关于java - 尝试从当前日期计算出生日期时,二元运算符 && 的操作数类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61048242/

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