你如何在java中的if / else语句之间加入一些东西? [英] How can you put something in between an if/else statement in java?
本文介绍了你如何在java中的if / else语句之间加入一些东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我有这样的事情:
if (blah) {
doSomething();
} else if (blahblah) {
doSomethingElse();
}
但我不能做别的东西,除非我插入一些东西在if和if else之间,我不能把这个东西放在if之前,因为在该函数发生之前需要if。有人可以帮忙吗?
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. Can someone help?
推荐答案
你可以使用2而不是if和if-else。
You can use 2 if instead of if and if-else.
if (blah) {
doSomething();
}
dosomethingyouwant();
if (blahblah && !blah) {
doSomethingElse();
}
这篇关于你如何在java中的if / else语句之间加入一些东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文