slamalon
slamalon

Reputation: 37

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.

Upvotes: 0

Views: 1041

Answers (1)

Amol Patil
Amol Patil

Reputation: 1005

You have to use

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

Upvotes: 1

Related Questions