简体   繁体   中英

how to put a boolean method from another class in an if statement

Sorry if this question is too bare bones, but simply put, what is the correct way to do this:

OtherClass ClassObj = new OtherClass();

if(ClassObj.booleanMethod().equals(true)){
    do a thing
}

I know this is a basic logical error and misconception, I just haven't been able to find the answer so far.

You have to use

if(classObj.booleanMethod()){
    do a thing if its true
}else{
    do a thing if its false
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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