英文:
Boolean methods return expression is not showing the result in output console
问题
以下是翻译好的内容:
这段代码用于显示isTeen是否为True/False。下面的代码提供了正确的输出,但然后没有在IntelliJ输出控制台中打印出来。
public static boolean hasTeen(int age1, int age2, int age3) {
if ((age1 >= 13 && age1 <= 19) || (age2 >= 13 && age2 <= 19) || (age3 >= 13 && age3 <= 19)) {
return true;
}
return false;
}
public static boolean isTeen(int age1) {
if (age1 >= 13 && age1 <= 19) {
return true;
}
return false;
}
我期望根据给定的输入显示TRUE/FALSE,但是没有打印任何内容。
英文:
The code is written to display whether isTeen is True/False.
the below code is giving the correct output. but, then it's not printing in the IntelliJ output console.
public static boolean hasTeen(int age1, int age2, int age3) {
if ((age1 >= 13 && age1 <= 19) || (age2 >= 13 && age2 <= 19) || (age3 >= 13 && age3 <= 19)) {
return true;
}
return false;
}
public static boolean isTeen(int age1) {
if (age1 >= 13 && age1 <= 19) {
return true;
}
return false;
}
}
I would expect to display TRUE/FALSE based on the input given. but, nothing printed.
答案1
得分: 2
使用 System.out.println()
在控制台上打印输出。
编辑
在您的情况下,您的主方法将如下所示。
public static void main(String[] args){
System.out.println(hasTeen(13,42,45));
System.out.println(isTeen(19));
System.out.println(isTeen(29));
}
英文:
Use System.out.println()
to print output on the console.
Edit
In your case, your main method would look as below.
public static void main(String[] args){
System.out.println(hasTeen(13,42,45));
System.out.println(isTeen(19));
System.out.println(isTeen(29));
}
答案2
得分: 0
以下是要翻译的内容:
返回结果,但您没有捕获结果。
尝试这个一次
System.out.println(hasTeen(13,42,45));
System.out.println(isTeen(19));
System.out.println(isTeen(25));
英文:
It is returning but you are not Catching the result.
Try this once
System.out.println(hasTeen(13,42,45));
System.out.println(isTeen(19));
System.out.println(isTeen(25));
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论