开发者

Does if with ifelse ,ifelse needs to have at least one else statement

if ()
{}else if (){}
else if (){}
else if (){}
else开发者_开发知识库{}

Do we need to have at least one else {}?


Nope, an else block is not required.

The following is perfectly valid:

if (....) {
}
else if (...) {
}


You do not need an else. If your conditions fail, no code will be executed without the else.


No it is not. Neither is it required when only using an if statement. Your also asking if it needs at least one else statement. The maximum is 1 else statement. You can not have if(){}else{}else{} (Wouldn't make sense either :P)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜