否则,如果出错-Java'('预期-参加在线课程。为在线测验编写了一些代码,并且系统接受了该代码。第二个测验问题非常相似。代码将无法运行,并且不确定是什么错误。语法结构似乎与第一个有效的答案相似。我缺少什么?Java业余爱好者新手...

package com.JonEKreski;

public class Main {

    public static void main(String[] args) {

        shouldWakeUp(false, -1);
        System.out.println("Dog is barking = " + barking);
    }
    public static boolean shouldWakeUp(boolean barking, int hourOfDay) {
        if ((hourOfDay < 0) || (hourOfDay > 23)) {
            barking = false;
        } else if {
            ((hourOfDay < 8) || (hourOfDay > 22));
            barking = true;
        } else {
            barking = false;
        }
        return barking;
    }
}

最佳答案

更正是否应该

else if ((hourOfDay < 8) || (hourOfDay > 22)){
    barking = true;
}

09-28 06:04