简体   繁体   English

您如何在Java的if / else语句之间放置一些内容?

[英]How can you put something in between an if/else statement in java?

So I have something like this: 所以我有这样的事情:

if (blah) {
    doSomething();
} else if (blahblah) {
    doSomethingElse();
}

But I can't do the "something else" unless I insert something in between the "if" and the "if else", and I can't put that something before the "if" because that something needs the "if" to happen before that function takes place. 但是,除非我在“ if”和“ if else”之间插入一些内容,否则我将无法进行“其他”操作,并且我不能将某些内容放置在“ if”之前,因为某些内容需要使用“ if”在该功能发生之前发生。 Can someone help? 有人可以帮忙吗?

You can use 2 if instead of if and if-else. 您可以使用2 if代替if和if-else。

if (blah) {
doSomething();
} 
dosomethingyouwant();
if (blahblah && !blah) {
doSomethingElse();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM